Safety of Blue / Green Garlic
The answer is anthocyanins, the same that can turn ginger blue and are responsible for purple snap beans and cabbage. The reaction occurs relative to pH and is perfectly safe. Anthocyanins are present in their range of colors in many foods including cabbage, ginger, garlic, and berries. When used as an additive, they have the E number E163.