A few weeks ago, the Epi kitchen was knee-deep in pickling jars and we noticed something weird: all the pickled garlic had turned blue. Shocked, we reached out to some food scientists to figure out what the heck was going on.

Turns out, the scientists are nearly as stumped as we were when it comes to blue garlic. “We don’t know a lot about this,” says Dr. Luke LaBorde of Penn State University’s Department of Food Science. “It’s definitely enzymatic and nonenzymatic reactions occurring in the garlic, but we really don’t know entirely why.” Only a few papers have been written on the subject, but it's not as if the study of color-changing garlic is a booming field.

As far as they can tell, garlic enzymes—which give it that distinct flavor—break down over time. Naturally occurring sulfur in the garlic interacts with those enzymes, occasionally turning it slightly green or blue. Sometimes the color change happens, sometimes it doesn't. Shifts in temperature, pH, and the age of the garlic can also come into play, so heating it or mixing it with acid might have some affect.

Which means blue garlic is not just a pickling problem. Anytime you cook garlic or onions in a high-acid solution—say you sauté them, then deglaze the pan with lemon juice—this issue could occur. It also might happen simply by storing garlic for too long.

If you want to avoid the smurf coloration, using fresh garlic is your best best, says LaBorde. Older garlic apparently colors more often. In fact, in China, where a pickled garlic called Laba is prized for its green and blue color, garlic is aged for several months to increase the coloration.

LaBorde also suggests blanching: "Try putting them in hot water for a short period of time, which might slow down or inactivate the enzymes."

The good news is, the color doesn't affect the taste or safety of the garlic. "Nothing suggests the color affects the taste or flavor of the food," says LaBorde. "You're just rearranging some molecules inside the garlic. Even if it’s blue, it should be okay."