Magnesium is an essential mineral involved in hundreds of enzyme reactions. It contributes to normal muscle and nerve function, energy production, protein synthesis and maintenance of bones. It is found in many everyday foods, especially nuts, seeds, legumes, whole grains and green vegetables. A varied eating pattern is usually the best starting point for meeting magnesium needs.
What magnesium does
Magnesium helps the body use energy, supports normal nerve signalling and muscle contraction, and contributes to the structure of bones. It is involved in maintaining normal heart rhythm and blood glucose regulation. These functions are important, but magnesium supplements should not be viewed as a general cure for cramps, insomnia, anxiety or other symptoms.
Foods that provide magnesium
Good sources include pumpkin seeds, almonds, cashews, peanuts, beans, lentils, chickpeas, oats, whole grains, spinach and other leafy greens. Some mineral waters also contain magnesium. Dark chocolate can contribute, but it may also contain added sugar and should be considered as one food rather than a supplement. The magnesium content of foods varies by growing conditions and processing.
Why whole grains and pulses help
Magnesium is present in the outer layers of grains, so refining can reduce its content. Choosing oats, whole-wheat foods, brown rice or millets more often can help increase intake. Beans and lentils contribute magnesium as well as fibre and plant protein, making them useful staples in many cuisines.

How much is needed?
Magnesium requirements vary with age, sex and life stage. Most healthy people can obtain enough through food, although some medical conditions and medicines can affect status. The body regulates magnesium through the gut and kidneys, so kidney function is especially important when considering supplements.
Magnesium supplements: use caution
Supplemental magnesium can cause diarrhoea, nausea and abdominal cramping, especially at higher doses. People with kidney disease may be at risk of magnesium accumulating and should not self-prescribe. Magnesium can also interfere with absorption of certain antibiotics, bisphosphonates and other medicines. Ask a pharmacist or clinician about safe timing and whether a supplement is appropriate.
Do cramps mean you need magnesium?
Muscle cramps can have many causes, including exercise, dehydration, medicines, nerve conditions and electrolyte changes. A cramp does not automatically indicate magnesium deficiency. If cramps are frequent, severe or accompanied by weakness or other symptoms, seek medical advice rather than repeatedly increasing supplement doses.
Simple ways to include more magnesium
- Add nuts or seeds to oats, yoghurt or salads.
- Use beans, chickpeas or lentils in regular meals.
- Choose whole grains where practical.
- Include leafy greens in cooked dishes, soups or sides.
- Keep meals varied rather than depending on one high-magnesium food.
Frequently asked questions
Can food provide enough magnesium?
For many people, yes. A varied diet with pulses, nuts, seeds, whole grains and vegetables can contribute substantially.
Is magnesium good for sleep?
Magnesium is involved in normal nerve and muscle function, but evidence that supplements improve sleep for everyone is limited. Persistent sleep problems deserve a broader assessment.
Can I take magnesium with other medicines?
It can interact with some medicines. Check with a pharmacist or clinician before starting a supplement, especially if you take regular prescriptions.
Key takeaway
Magnesium supports many normal body functions and is widely available in everyday foods. Include pulses, whole grains, nuts, seeds and green vegetables, and use supplements only when there is a clear reason and appropriate professional guidance.