If you have frequent leg cramps, one reason could be that your body needs more of the mineral magnesium. A 2017 study reported that up to two-thirds of the American population is magnesium deficient.

Magnesium is the fourth most abundant mineral in the body and is essential for regulating your body’s functioning. It’s involved in more than 300 of your body’s biochemical processes, including muscle contraction and nerve transmission.

Magnesium is a widely used remedy for leg cramps. But the evidence for its effectiveness is very limited. Here we’ll look at what studies report and what you can do for leg cramps.

Summary

Having a magnesium deficiency can be a cause of muscle cramps. And it’s common for people to need more magnesium. But, based on clinical studies, magnesium supplements have not proven to be an effective treatment for muscle cramps. There are still things you can do, with or without magnesium, to alleviate leg cramps.

Healthline

Anecdotally, it does help some people. And it’s safe to use.

If you’re magnesium deficient, increasing your magnesium levels may have other beneficial effects.

Athletes, in particular, need adequate levels of magnesium for performance. Magnesium has been found useful in treating people with conditions such as:

  • asthma
  • osteoporosis
  • migraine headaches
  • diabetes
  • heart disease
  • depression

How much magnesium you need depends on your age and sex. According to the National Institutes of Health (NIH), men over 70 and teenage girls are the most likely groups to be magnesium deficient.

Suggested amounts of magnesium

  • 400–420 milligrams a day for men
  • 310–320 mg a day for women
  • 350–360 mg a day for pregnant women
Healthline

Some drugs can interact with magnesium. If you’re taking any medications, check with a pharmacist or doctor before taking magnesium supplements.

Eating foods rich in magnesium can ensure that your levels meet the suggested daily intake. Your body absorbs about 30 percent to 40 percent of the magnesium you get from your diet.

At the top of the list for magnesium content per serving are:

  • almonds (80 mg)
  • spinach (78 mg)
  • cashews (74 mg)
  • peanuts (63 mg)
  • soy milk (61 mg)
  • shredded wheat cereal (61 mg)

You can also try magnesium supplements. These are available in many forms such as magnesium oxide, magnesium chloride, and magnesium citrate. A 2015 study of the medical uses of magnesium recommends taking magnesium citrate because it’s more easily absorbed by the body.

It’s also recommended that your magnesium intake is in proportion to your calcium intake, with magnesium in your diet being about half to two thirds of your calcium intake.

For example, if your magnesium intake is 500–700 mg, your calcium intake should be 1,000 mg. Or, more simply put: Eat a variety of foods and include good sources of calcium and foods that have magnesium.

Fast facts about magnesium deficiency

  • Your body absorbs up to 30 percent less magnesium from foods as you age.
  • Smoking and alcohol use reduce magnesium levels.
  • Processed foods have lower levels of magnesium.
  • Many common drugs, such as statins and antacids, reduce magnesium absorption.
  • Low vitamin D levels reduce absorption of magnesium.
Healthline

Magnesium is widely used to treat leg cramps, particularly in Latin America and Europe. But almost all of the many clinical studies of magnesium treatment for cramps found it to be ineffective.

Here are some of the specific study results:

A 2017 study of 94 adults compared whether magnesium oxide capsules were better than a placebo capsule for reducing night cramps. The randomized clinical trial concluded that magnesium oxide supplements are no better than a placebo in reducing cramps.

A 2013 review of seven randomized trials of magnesium for leg cramps found that magnesium therapy doesn’t appear to be effective for the general population. The review noted that it may have a small positive effect for pregnant women.

A 2010 assessment by the American Academy of Neurology reported:

  • A 2002 study of 58 people using magnesium citrate found no significant improvement in the number of cramps.
  • A 1999 study using magnesium sulfate found that it was no better than a placebo in reducing the frequency, severity, or duration of cramps among 42 study participants.

Other factors to consider

  • Supplements can still be okay to take. The magnesium studies note that magnesium supplements are safe and are not expensive.
  • You might be low in something else. One possible reason for the lack of effectiveness on cramps in the magnesium studies is the complex relationship between magnesium and other basic nutrients. For example, calcium and potassium are also involved in muscle cramping. If a lack of one of these other nutrients is causing the muscle cramps, then magnesium wouldn’t help.
  • Magnesium does help some people. Although the majority of the available research shows no overall correlation between using magnesium and reducing leg cramps, some study participants did report magnesium more effective than a placebo.

When increasing your magnesium intake doesn’t help stop your cramps, there are other things you can try. Stretching can be most effective, according to a 2016 review of studies.

Stretching

Here are three stretches you can try if you’re actively having a leg cramp:

  • If your calf muscle is cramping, reach down and pull your toes toward your head until the cramp eases.
  • Try lunging forward with the leg that isn’t cramped, stretching out the cramped leg behind you.
  • Stand on your toes for a few seconds.

There’s evidence that stretching before you go to sleep reduces the frequency and severity of night leg cramps.

A 2012 study of 80 adults over age 55 found that those who stretched their calves and hamstrings before bed had fewer and less painful leg cramps during the night.

In general, walking around may relax your leg muscles and ease leg cramps.

Massage

Gently rub the muscle area that’s cramped.

Ice or heat

  • Use an ice pack or a heating pad on the cramp, for 15 to 20 minutes at a time. (Wrap the ice in a towel or cloth, so that it’s not directly on the skin.)
  • Take a hot bath or shower.

Hydration

Drinking some water may help with a cramp. For prevention, it’s important to stay hydrated.

Consider not consuming alcohol. A 2018 study reported that alcohol consumption was strongly associated with having leg cramps at night. The authors note that more studies would be necessary to confirm causality.

Medication

Try over-the-counter nonsteroidal anti-inflammatory drugs (NSAIDs) to reduce pain from muscle spasms. Topical pain-relieving creams, such as Bengay or Biofreeze, may help.

You could also try a non-prescription muscle relaxant.

Getting more magnesium from your diet or from a supplement seems to help some people with their leg cramps, but the scientific evidence doesn’t support the effectiveness of magnesium for cramps.

Magnesium citrate may be the most effective type if you want to try a supplement.

If you’re magnesium deficient, there may be other benefits from increasing your intake of this nutrient. And other remedies are available for leg cramping that may help.