Magnesium is the most widely recommended supplement for leg cramps, though the evidence is more nuanced than most people expect. Several other vitamins and minerals also play a role, including vitamin D, vitamin B complex, and potassium. Which one helps most depends on what’s actually driving your cramps.
Magnesium: The First-Line Supplement
Magnesium is involved in how your muscles relax after contracting. It acts as a natural calcium blocker at the cellular level. When magnesium drops too low, calcium floods into muscle cells unchecked, triggering cramps, spasms, and tightness. This is why magnesium is the supplement most people reach for, and most doctors suggest, when leg cramps become a recurring problem.
The clinical evidence, however, is mixed. A review published by the American Academy of Family Physicians looked at multiple trials and found that for general nighttime leg cramps in older adults, magnesium didn’t significantly outperform a placebo over four weeks. But a larger 2021 trial that ran for 60 days told a different story: participants taking 226 mg of magnesium daily saw cramp frequency drop from about 5.4 episodes per week to 1.9, compared to a smaller drop (6.4 to 3.7) in the placebo group. Cramp duration also fell sharply. The takeaway is that magnesium may need more than a month to show meaningful results.
Not all forms are equal. Magnesium citrate and magnesium glycinate are better absorbed than magnesium oxide, which is poorly absorbed and more likely to cause loose stools. The tolerable upper intake from supplements is 350 mg per day for adults. Going above that commonly causes diarrhea or stomach cramps, which is counterproductive.
Vitamin D and Muscle Sensitivity
Vitamin D deficiency doesn’t just weaken bones. It directly changes how nerves interact with muscle tissue. Research in the Journal of Neuroscience found that when vitamin D levels drop, pain-sensing nerve fibers in skeletal muscle nearly double in density. This means the muscle becomes hypersensitive, more reactive to normal stimuli, and more prone to painful cramping and spasms.
This nerve overgrowth appears to be a direct effect of low vitamin D on nerve cells. When vitamin D levels in the study fell below normal ranges, nerve fiber outgrowth increased by up to 60%. The practical implication: if you’re getting frequent leg cramps and your vitamin D is low (which is common, especially in winter months or if you spend little time outdoors), correcting that deficiency may reduce how intensely and how often your muscles cramp. A simple blood test can check your levels.
B Vitamins and Nerve Function
A vitamin B complex supplement has shown some benefit for leg cramps, likely because several B vitamins are essential for healthy nerve signaling. B6, B12, and B1 all support the nerves that tell your muscles when to contract and when to stop. When these vitamins are deficient, nerve signals can misfire, and muscles may contract involuntarily.
Vitamin B6 also has an interesting relationship with magnesium. Research suggests B6 facilitates magnesium absorption and its uptake into cells, meaning the two may work better together than either does alone. A randomized controlled trial found that people under severe stress who took magnesium combined with B6 saw greater benefits than those taking magnesium by itself. If you’re supplementing magnesium for cramps, pairing it with a B complex is a reasonable strategy.
Potassium’s Role
Potassium works alongside magnesium to regulate muscle contractions. Low potassium (from sweating, dehydration, or certain medications like diuretics) is a well-known trigger for muscle cramps. Most people can get adequate potassium through food: bananas, potatoes, avocados, and leafy greens are all rich sources. Potassium supplements are typically kept at low doses (99 mg per pill) because excess potassium can cause dangerous heart rhythm problems, so food sources are generally preferred over high-dose pills.
What Vitamin E Won’t Do
Vitamin E is sometimes suggested as a cramp remedy, but the evidence doesn’t support it. A clinical trial testing 800 IU of vitamin E nightly against a placebo found no effect on the number of cramps, the number of nights with cramps, or sleep disturbance. This is one you can skip.
Where to Start
If you’re getting occasional leg cramps, especially at night, the most practical approach is to start with magnesium (in citrate or glycinate form, around 200 to 350 mg daily) and give it at least six to eight weeks. Adding a B complex supplement is low-risk and may improve how well your body uses the magnesium. If you haven’t had your vitamin D level checked recently, that’s worth doing, since deficiency is widespread and correctable.
People taking diuretics, proton pump inhibitors, or immunosuppressive medications should be aware these drugs can deplete magnesium. If you have kidney disease, magnesium supplementation requires caution because damaged kidneys can’t clear excess magnesium efficiently, and levels that climb too high are associated with serious complications. In that case, getting your magnesium level tested before supplementing is important.
Dehydration and electrolyte imbalance remain the most common and most fixable causes of leg cramps. Before adding any supplement, make sure you’re drinking enough water and eating a diet that includes magnesium-rich foods like nuts, seeds, dark chocolate, and whole grains. Supplements work best when they’re filling an actual gap, not substituting for basic nutrition.

