Green vegetables such as spinach provide magnesium because of the abundance of chlorophyll molecules, which contain the ion. Nuts (especially Brazil nuts, cashews and almonds), seeds (e.g., pumpkin seeds), dark chocolate, roasted soybeans, bran, and some whole grains are also good sources of magnesium.
Although many foods contain magnesium, it is usually found in low levels. As with most nutrients, daily needs for magnesium are unlikely to be met by one serving of any single food. Eating a wide variety of fruits, vegetables, and grains will help ensure adequate intake of magnesium.
Because magnesium readily dissolves in water, refined foods, which are often processed or cooked in water and dried, in general, are poor sources of the nutrient. For example, whole-wheat bread has twice as much magnesium as white bread because the magnesium-rich germ and bran are removed when white flour is processed. The table of food sources of magnesium suggests many dietary sources of magnesium.
"Hard" water can also provide magnesium, but "soft" water contains less of the ion. Dietary surveys do not assess magnesium intake from water, which may lead to underestimating total magnesium intake and its variability.
Too much magnesium may make it difficult for the body to absorb calcium. Not enough magnesium can lead to hypomagnesemia as described above, with irregular heartbeats, high blood pressure (a sign in humans but not some experimental animals such as rodents), insomnia, and muscle spasms (fasciculation).  However, as noted, symptoms of low magnesium from pure dietary deficiency are thought to be rarely encountered.
Following are some foods and the amount of magnesium in them:
* Pumpkin seeds, no hulls ( cup) = 303 mg
*Chia seeds, ( cup) = 162 mg
* Buckwheat flour ( cup) = 151 mg
* Brazil nuts ( cup) = 125 mg
* Oat bran, raw ( cup) = 110 mg
* Cocoa powder ( cup) = 107 mg
* Halibut (3 oz) = 103 mg
* Almonds ( cup) = 99 mg
* Cashews ( cup) = 89 mg
* Whole wheat flour ( cup) = 83 mg
* Spinach, boiled ( cup) = 79 mg
* Swiss chard, boiled ( cup) = 75 mg
* Chocolate, 70% cocoa (1 oz) = 73 mg
* Tofu, firm ( cup) = 73 mg
* Black beans, boiled ( cup) = 60 mg
* Quinoa, cooked ( cup) = 59 mg
* Peanut butter (2 tablespoons) = 50 mg
* Walnuts ( cup) = 46 mg
* Sunflower seeds, hulled ( cup) = 41 mg
* Chickpeas, boiled ( cup) = 39 mg
* Kale, boiled ( cup) = 37 mg
* Lentils, boiled ( cup) = 36 mg
* Oatmeal, cooked ( cup) = 32 mg
* Fish sauce (1 Tbsp) = 32 mg
* Milk, non fat (1 cup) = 27 mg
* Coffee, espresso (1 oz) = 24 mg
* Whole wheat bread (1 slice) = 23 mg