Does Magnesium Help Leg Cramps? Everything to Know

Medically Reviewed By Adam Bernstein, MD, ScD
Was this helpful?

Magnesium supplements are widely used for the prevention and treatment of leg cramps. Because magnesium is important for muscle contraction, having a deficiency in this mineral may be causing your leg cramps. Magnesium is essential for regulating your body’s functions. It’s involved in over 300 biochemical reactions in the body, including muscle contraction, electrical conductance, and nerve transmission.

A 2017 study reported that up to two-thirds of Americans do not get enough magnesium from their diet. This may lead to muscle cramps.

Leg cramps are involuntary muscle spasms that can occur anywhere in your leg. They happen most commonly in the calf. As the muscle tenses up, you may experience moderate to severe pain and tightness in the area.

This article discusses the evidence for magnesium’s use as a treatment for leg cramps. It also looks at the best sources of magnesium and recommendations for how much you should take.

Is magnesium good for leg cramps?

A person is resting their legs on an exercise ball.
Anfisa&friends/Stocksy United

Magnesium plays a critical role in the way your nervous system controls your muscles, including muscle contraction. A deficiency in magnesium may contribute to muscle cramps. Learn more about magnesium deficiency.

Because of its role in muscle contraction, magnesium supplements may be recommended for preventing cramps. However, evidence for this is limited, and more research may be needed.

more research may be needed.A 2021 randomized control trial looked at magnesium supplements used to treat nocturnal leg cramps. It found a significant reduction in both the frequency and duration of cramps in participants who took the supplement. This group also reported better sleep quality.

However, a 2017 randomized control trial found that magnesium oxide supplements are not significantly better than a placebo in reducing nocturnal cramps.

A 2020 meta-analysis reported that magnesium supplementation is unlikely to have a significant impact on older adults experiencing leg cramps. It also found conflicting research on the benefits for pregnancy-associated leg cramps.

Similarly, a 2021 meta-analysis concluded that oral magnesium supplementation is not effective for treating leg cramps during pregnancy.

The results of these studies are mixed. This may be due to differences in study populations such as age, overall health, and variations in magnesium absorption.

How much magnesium should I take for leg cramps?

Magnesium supplements are sometimes used to treat leg cramps. However, there is limited clinical evidence for their effectiveness in people without a magnesium deficiency.

Supplementing with magnesium may be beneficial for those who are pregnant. An older 2012 study found that pregnant people who took 300 milligrams of magnesium experienced less frequent and less intense leg cramps compared to a placebo.

According to the National Institutes of Health, the recommended daily allowance (RDA) for magnesium for adults aged 19 or older is 400–420 mg for males and 310–320 mg for females. The RDA for those who are pregnant is 350–360 mg.

The tolerable upper intake level for magnesium is 350 mg for adults. Taking more than this per day may cause mild diarrhea or gastric cramps in any individual.

Approximately 48% of people in the United States do not get enough magnesium from food and beverages they consume. This data comes from the 2013–2016 National Health and Nutrition Examination Survey.

Learn about when you should take magnesium.

What are some good sources of magnesium?

Magnesium is found naturally in many foods. Your body absorbs about 30–40% of the magnesium you get from your diet.

Some good sources of magnesium include:

  • pumpkin seeds
  • dark leafy greens, such as spinach
  • avocados
  • beans and legumes
  • chia seeds
  • almonds
  • edamame
  • cashews
  • soy milk

Learn more about magnesium supplements.

When should I see a doctor?

Muscle cramps often go away on their own but can sometimes be related to:

  • an underlying medical condition
  • insufficient blood flow
  • mineral deficiency or electrolyte imbalance
  • nerve compression

You should contact your doctor if:

  • you frequently experience leg cramps
  • leg cramps are interfering with your sleep
  • you have numbness or swelling in your legs
  • you have any other symptoms or concerns

Learn more about the symptoms of leg cramps.

What are some other treatments for leg cramps?

If increasing your magnesium intake isn’t helping to prevent leg cramps, there are some other things you can try.

According to a 2016 review, stretching can be effective at stopping muscle cramps.

Other treatments that may be helpful include:

  • massaging the area
  • applying a heating pad
  • applying ice to the area
  • hydrating, especially with electrolytes
  • walking
  • taking over-the-counter muscle relaxants

Learn more about the treatments for leg cramps.

Other frequently asked questions

Here are some more frequently asked questions about leg cramps.

What is the best vitamin for leg cramps?

There is some evidence that taking a supplement containing a complex of B vitamins can help to prevent leg cramps. B vitamins include:

  • B1 (thiamine)
  • B2 (riboflavin)
  • B3 (niacin)
  • B5 (pantothenic acid)
  • B6
  • B7 (biotin)
  • B9 (folate)
  • B12

What’s better for leg cramps: potassium or magnesium?

Potassium and magnesium are critical electrolytes. They are both important for conducting electrical charges in the body, which enable your muscles to contract.

What is your body lacking when you have leg cramps?

Leg cramps may be due to a variety of nutritional deficiencies or an underlying health condition. A deficiency in magnesium is one possible cause.

What do leg cramps at night mean?

Experiencing nocturnal cramps is fairly common. A 2017 study found that about 30% of adults reported having nocturnal leg cramps at least 5 times a month.

In general, nocturnal leg cramps are likely to be related to nerve problems. However, no single cause has been identified. Leg cramps at night can also be due to an underlying health condition. The risk of experiencing leg cramps at night increases during pregnancy.


Magnesium is a mineral that plays an essential role in over 300 biochemical reactions in the body. These include muscle contractions and electrical transmission in nerves. Almost half of people in the United States do not get enough magnesium from their diet.

Because of its safety and level of tolerability, magnesium has been widely used to address leg cramps. While there is some clinical evidence that magnesium supplementation can improve symptoms of leg cramps, study results are mixed.

You may only benefit from supplementing with magnesium if you have a deficiency. However, it’s still important to make sure you are meeting the RDA for magnesium to maintain your overall health.

Leg cramps can have a variety of causes, including nutritional deficiencies, certain medical conditions, or inactivity. Contact your doctor as soon as you have concerns about leg cramps.

Was this helpful?
Medical Reviewer: Adam Bernstein, MD, ScD
Last Review Date: 2022 Nov 18
View All Food, Nutrition and Diet Articles
THIS TOOL DOES NOT PROVIDE MEDICAL ADVICE. It is intended for informational purposes only. It is not a substitute for professional medical advice, diagnosis or treatment. Never ignore professional medical advice in seeking treatment because of something you have read on the site. If you think you may have a medical emergency, immediately call your doctor or dial 911.