Magnesium is a mineral that helps your body in many ways. It supports your brain, muscles, bones, heart, and immune system. You can get magnesium from foods like spinach, almonds, peanut butter, avocados, and potatoes. You can also take magnesium supplements to get more of this mineral.