Chopped garlic turns bluish in vinegar due to a reaction between sulfur compounds in the garlic and amino acids, which, in the presence of acid (vinegar), form blue-colored compounds. These compounds are harmless.
Garlic contains alliin and other sulfur-containing compounds. When garlic is chopped or crushed, the enzyme alliinase converts alliin into allicin, which then breaks down into various other sulfur compounds. These sulfur compounds can react with amino acids naturally present in garlic.
Vinegar is an acidic solution. The acidity of the vinegar facilitates the reaction between the sulfur compounds and amino acids. This reaction produces pyrroles, which can link together to form larger, ring-shaped molecules. These larger molecules can absorb light in a way that makes them appear blue or greenish-blue. The intensity of the color depends on factors like the garlic variety, the acidity of the vinegar, and the storage conditions. The color change is a natural chemical reaction and does not indicate spoilage or toxicity.
To minimize the blueing effect, use fresh garlic and avoid prolonged exposure to acidic environments. You can also try blanching the garlic briefly before adding it to the vinegar to denature the enzymes involved in the reaction.