Natural food dyes are gaining in popularity over petroleum-based synthetic dyes (artificial food coloring) for many reasons — health, sustainability and (most important) the beautiful colors that nature provides.
I love baking shows (don’t we all?) and enjoy seeing what food ingredients are used to dye cake batters and frostings. I looked into natural food dyes and decided to store my findings in a Wolfram Language entity store. Here’s how I did it.

Colors

First, I chose colors popular in baking, particularly for birthday cakes and other celebration treats:
In[]:=
Interpreter["Color"][{"Pink","Red","Orange","Yellow","Purple","Green","Brown"}]
Out[]=
{
,
,
,
,
,
,
}
The neon yellow and green are perfect for a vibrant Mardi Gras king cake, but I decided to use ColorData to choose softer hues:
In[]:=
Interpreter["Color"][{"Pink","Red","Orange",ColorData["HTML","Gold"],"Purple",ColorData["HTML","ForestGreen"],"Brown"}]
Out[]=
{
,
,
,
,
,
,
}

Foods

Next, I determined what foods would provide these colors and retrieved those food entities from the Wolfram Knowledgebase:
In[]:=
foodEntities=Interpreter["Food"][{"beets","raspberries","pomegranate juice","carrot juice","paprika","turmeric","blueberry juice","spinach","avocado","cinnamon"}]

Amounts

I used LLMSynthesize to provide estimates of the amount of each food needed to dye 1 cup of frosting:
In[]:=
LLMSynthesize["How much raspberry puree do I use to dye 1 cup of white frosting pink? Please provide a concise answer. It's okay to estimate."]
Out[]=
Start with about 2 tablespoons of raspberry puree and adjust to reach your desired color.
As the LLM reminded me, the amount will vary depending upon the color I want — a subtle shade or a bold, bright pink.

Calories

Using the estimated amounts, I retrieved the calories for each food from the Wolfram Knowledgebase:
In[]:=
EntityValueEntityInstance
food
food type group
:
juices
FOOD TYPE GROUP
added food types
:exactlynone
source food types
:
pomegranate
FOOD TYPE
,
3
tbsp
,"AbsoluteTotalCaloriesContent"
Out[]=
30.
Cal

Pigments

Next, I created an LLMFunction to obtain the pigments responsible for each food’s color:
In[]:=
pigmentFinder=LLMFunction["name of the primary pigment in `1`"]
Out[]=
LLMFunction
​
Content: name of the primary pigment in
1
Parameters: 1

In[]:=
pigmentFinder[{"beets","raspberries","pomegranate juice","carrot juice","paprika","turmeric","blueberry juice","spinach","avocado","cinnamon"}]
Out[]=
beets - Betaninraspberries - Anthocyaninspomegranate juice - Anthocyaninscarrot juice - Beta-carotenepaprika - Capsanthinturmeric - Curcuminblueberry juice - Anthocyaninsspinach - Chlorophyllavocado - Chlorophyllcinnamon - Cinnamaldehyde

Molecules

I used each pigment’s SMILES string to display its molecule structure with MoleculePlot3D. This is betanin, the pigment in beets:
In[]:=
MoleculePlot3D[Molecule["C1[C@H](N=C(C=C1/C=C/N2[C@@H](CC3=CC(=C(C=C32)O)O[C@H]4[C@@H]([C@H]([C@@H]([C@H](O4)CO)O)O)O)C(=O)O)C(=O)O)C(=O)O"]]
Out[]=

Entity Store

I compiled all of my data into an EntityStore that I can use as a reference now and continue to expand in the future:
customEntityStore=​​EntityStore

​​
Out[]=
EntityStore
Type: NaturalFoodDyes
Entities: {BeetJuice,RaspberryPuree,PomegranateJuice,…,Spinach,Avocado,Cinnamon} (10)
Properties: {Color,Amount,Pigment,Molecule,Calories} (5)

I registered my new “NaturalFoodDyes” entity store, then checked for the entities and properties I created:
In[]:=
EntityRegister[customEntityStore]
Out[]=
{NaturalFoodDyes}
In[]:=
EntityList["NaturalFoodDyes"]
Out[]=

BeetJuice
,
RaspberryPuree
,
PomegranateJuice
,
CarrotJuice
,
Paprika
,
Turmeric
,
BlueberryJuice
,
Spinach
,
Avocado
,
Cinnamon

In[]:=
EntityProperties["NaturalFoodDyes"]
Out[]=

Amount
,
Calories
,
Color
,
Molecule
,
Pigment


Dataset

I was ready to display my new entity store as a dataset:
In[]:=
Labeled[EntityValue["NaturalFoodDyes","Dataset"],"To Dye 1 Cup White Frosting",Top]
Out[]=
To Dye 1 Cup White Frosting
Beet Juice
Amount
1tbsp
Calories
5.0Cal
5 total ›
Raspberry Puree
Amount
2tbsp
Calories
8.8Cal
5 total ›
Pomegranate Juice
Amount
3tbsp
Calories
30.Cal
5 total ›
Carrot Juice
Amount
3tbsp
Calories
15.Cal
5 total ›
Paprika
Amount
1tsp
Calories
0Cal
5 total ›
Turmeric
Amount
2tsp
Calories
0Cal
5 total ›
Blueberry Juice
Amount
3tbsp
Calories
20.Cal
5 total ›
Spinach
Amount
2tbsp
Calories
2.7Cal
5 total ›
Avocado
Amount
3tbsp
Calories
75.Cal
5 total ›
Cinnamon
Amount
2tsp
Calories
0Cal
5 total ›

Examples

With my entity store complete, I began retrieving and visualizing the natural food dye entities and properties.
Retrieved all associations for a named property:
Found entities with a specific property value:
Retrieved the amounts and calories for a sample of food dyes:
Created a plot of the calories to dye 1 cup frosting, matching the color of the data points to their dye color:
Retrieved pigments and their 3D molecule structures:

Conclusion

Have ideas for building your own food and nutrition entity store? There are many great topics to explore. I’m considering food preservatives, thickeners and emulsifiers. What about vitamins and minerals? I look forward to seeing what you create!

CITE THIS NOTEBOOK

Pretty in pink: creating an Entity Store of natural food dyes​
by Gay Wilson​
Wolfram Community, STAFF PICKS, April 10, 2024
​https://community.wolfram.com/groups/-/m/t/3156436