Have you ever had raspberries turn blue when baking muffins or cakes?
Some red fruits and vegetables contain a compound called anthocyanin that changes color when exposed to changes in acidity or alkalinity, according to Shirley Corriher, a food scientist. A red berry will stay red if it's paired with enough acid. But if the conditions become alkaline, the barry and the batter around it will turn blue.
To solve the problem, Corriher suggests using an acidic ingredient, such as lemon juice, buttermilk or sour cream, for some of the liquid of the recipe. Not much is needed, like a tablespoon or two.