What is the richest food in magnesium?

Organic. Also consider that the organic grown versions of those same foods will tend to be richer in magnesium. Our soils are magnesium depleted and have been for over 50 years. Conventionally grown (non-organic) food does not have as good nutrients as organic.
Magnesium foods. Spinach, kale, chard, seeds, nuts, chocolate, quinoa, yogurt, banana, peach, avocado, beans.
Magnesium-rich foods. There are multiple good sources of magnesium, but the winner is probably rice bran. Seeds like squash, pumpkin, and flax are also good ones. Maybe you'll be happy to know that dark chocolate is right up there with them -- along with brazil nuts!