Turning wobbly blobs of clear gelatin red or orange using natural ingredients takes beet juice and a touch of annatto from the seeds of a tropical tree.

But making gelatin green? That one is difficult for Simple Mixes, a company that makes naturally flavored and colored gelatin. Its founder, Malathy Nair, uses a blend of yellow turmeric extract with spirulina, an extract from algae that produces shades of green and blue.

But spirulina tends to form clumps (who wants floaties in gelatin?) and can have an off-putting taste that Nair describes as “seedy.” To overcome the unwelcome flavor, she has to use more natural lime flavor, making green the most expensive gelatin her company produces.

Even after all that, the gelatin isn’t a saturated, bright green. It’s dull. “I’m not that happy with how the green looks,” said Nair, who has a doctorate in food science.

Turning Jell-O green using natural colorings is one of the many challenges Kraft Heinz is likely to face after recently announcing that it will remove artificial dyes from its foods by the end of 2027. The manufacturer joins other food companies, including General Mills, Danone North America and PepsiCo, that are planning to dump artificial colors in the coming years.

Across the country, food scientists are mixing fruit and vegetable juices with spices in a race to create blends of colors that can replicate artificial dyes widely used now in foods, drinks and snacks.

The change comes after pressure from Health Secretary Robert F. Kennedy Jr. and others who aim to eliminate synthetic food dyes, which they say are dangerous to children’s health and development.

Colors derived from fruits, vegetables and plants are typically more muted and have a tendency to fade, especially if exposed to heat or light. Moreover, natural dyes tend to be more expensive, in part because greater quantities have to be used to achieve close to desired shades.

For food companies, some colors are easier to replicate naturally than others. Red can be produced from beet juice, red cabbage, radishes or even carmine, a vivid crimson dye derived from the crushed-up shell of the cochineal insect. Likewise, yellow can come from turmeric, safflower, golden beets and annatto.

Creating the base blue to mix with yellow to get green is a challenge because the color doesn’t naturally occur in nature. Blueberries, when crushed, create more of a dark red or even purple mash, rather than blue.

For green, there’s chlorophyll, a pigment found in spinach and kale, but it produces darker shades of green and is unstable, turning olive green or even brownish.

Spirulina was supposed to be the holy grail for the food and beverage industry, but it has its own challenges. An extract from algae, it creates a blue shade that is very close to Brilliant Blue, or Blue No. 1, a synthetic dye that tints the moons blue in Lucky Charms cereal and makes Gatorade Cool Blue bright in bottles.

In 2013, the Food and Drug Administration approved the petition by the candy company Mars, allowing the spirulina-derived extract called phycocyanin to become the first natural blue dye for food. It works fairly well when used in foods that have low temperatures and aren’t acidic, such as yogurt or ice cream, say food scientists.

And while spirulina is relatively easy to grow — it’s like algae that form naturally on a lake — manufacturing it for people to eat requires tightly controlled conditions.