Why do purple snap beans turn green when cooked?
This is another case for anthocyanins, the same compound that causes garlic and ginger to turn blue. Anthocyanins are pH sensitive, only appearing blue or purple when in the presence of acidity. As you cook the beans, the cells begin to rupture and lose water, which causes the acid around the anthocyanins to be diluted. As this happens, they lose their color allowing the green chlorophyll (which was always present) to show through.

The Science Behind Purple Beans