What Vitamin Deficiency Causes Leg Cramps?

Several vitamin and mineral deficiencies can cause leg cramps, but the ones most strongly linked are vitamin D, vitamin B12, and vitamin K2, along with the minerals magnesium, potassium, and calcium. Low levels of these nutrients affect how your muscles contract and relax, how your nerves fire, and how sensitive your muscle tissue becomes to stimulation. Figuring out which deficiency is behind your cramps depends on the pattern of your symptoms and, often, a simple blood test.

Vitamin D and Muscle Pain Sensitivity

Vitamin D deficiency is one of the most common nutritional shortfalls tied to leg cramps and broader muscle pain. Up to 93% of people reporting nonspecific musculoskeletal pain have vitamin D levels below 20 ng/mL, the threshold generally considered deficient. But the connection goes deeper than simple correlation.

Animal research published in The Journal of Neuroscience found that a vitamin D-deficient diet produces measurable deep muscle hypersensitivity within just two to four weeks. What happens at the cellular level is striking: the muscle tissue develops an overgrowth of pain-sensing nerve fibers while motor nerves stay unchanged. In other words, your muscles become physically wired to be more sensitive to pressure and contraction, which can make normal muscle activity feel painful and trigger cramping. Importantly, this hypersensitivity wasn’t caused by low calcium (a downstream effect of low vitamin D). Researchers actually found that increasing dietary calcium without fixing the vitamin D deficit made the sensitivity worse.

Vitamin B12 and Nerve-Driven Cramps

Vitamin B12 plays a critical role in maintaining the protective coating (myelin) around your nerves. When B12 drops too low, that coating deteriorates, a process called demyelination. Most people associate severe B12 deficiency with numbness or tingling, but it also causes more subtle neuromuscular symptoms, including cramps and painful leg spasms.

A case report in the journal Neurology noted that B12 deficiency “can have more discrete neuromuscular manifestations including cramps,” beyond the well-known symptoms of neuropathy and cognitive decline. The cramps happen because damaged nerve fibers become hyperexcitable. They fire signals to muscles when they shouldn’t, causing involuntary contractions. People who are vegan, over 60, or taking long-term acid-reducing medications are at higher risk for B12 deficiency and may not realize their leg cramps have a nutritional cause.

Vitamin K2: A Newer Finding

Vitamin K2 is a more recent addition to the conversation about leg cramps. A randomized clinical trial published in JAMA Internal Medicine tested 180 micrograms of vitamin K2 (the MK-7 form) taken nightly for eight weeks against a placebo. The results were notable: the vitamin K2 group experienced a significant drop in nighttime leg cramp frequency, with the difference between groups becoming measurable as early as the first week. Participants on K2 averaged about 1.6 fewer cramps per week compared to baseline, while the placebo group’s cramps actually increased slightly.

This is one of the few supplements to show a clear, rapid benefit for nocturnal leg cramps in a well-designed trial. The mechanism isn’t fully mapped, but vitamin K2 is involved in calcium regulation within soft tissues, which may help prevent the kind of inappropriate calcium signaling that triggers muscle spasms.

Potassium, Magnesium, and Calcium

These three minerals work together to control muscle contraction and relaxation, and a shortage in any one of them can cause cramping. They’re not vitamins, but they show up in nearly every conversation about leg cramps for good reason.

Potassium deficiency (hypokalemia) causes cramping, weakness, and fatigue. Clinical symptoms typically appear when serum potassium falls below 3 mmol/L, though a sudden drop can trigger cramps at higher levels. Significant muscle weakness sets in below 2.5 mmol/L. Hypokalemia rarely occurs alone. It’s commonly paired with low magnesium and low calcium, which can amplify cramping.

Magnesium is widely recommended for leg cramps, but the evidence is more complicated than most people realize. A randomized clinical trial of 94 adults published in JAMA Internal Medicine found that magnesium oxide supplements were no better than placebo for reducing nighttime leg cramps in older adults. Both groups improved, likely due to a placebo effect, which may explain why so many people swear by magnesium supplements despite the lack of hard evidence. That said, correcting a true magnesium deficiency (common in people who eat few vegetables, nuts, or whole grains) can still matter for overall muscle function.

Calcium works with magnesium to regulate muscle contractions. Low calcium (hypocalcemia) can cause muscle spasms and tetany, a more severe form of sustained cramping. Since vitamin D controls calcium absorption, a vitamin D deficiency often drags calcium levels down with it.

What Doesn’t Work

Vitamin E was once a popular recommendation for nighttime leg cramps. A crossover trial tested 800 IU of vitamin E at bedtime against placebo and found it was not effective in reducing cramp frequency, severity, or sleep disruption.

Quinine, a prescription medication sometimes used off-label for leg cramps, carries serious risks. The FDA has issued safety warnings stating that quinine should not be used for nighttime leg cramps. It can cause dangerous drops in platelets and a life-threatening condition affecting the blood and kidneys. The FDA concluded that the risks of using quinine for cramps outweigh any potential benefit.

Leg Cramps vs. Restless Legs

It’s worth knowing the difference between true muscle cramps and restless leg syndrome (RLS), because the causes and treatments diverge. Leg cramps involve a sudden, painful, involuntary contraction of the muscle, usually the calf. RLS involves an uncomfortable urge to move your legs, typically during rest or in the evening, with partial or total relief from walking or stretching. RLS is strongly linked to iron deficiency rather than the vitamin deficiencies discussed above. If your symptoms are more of a crawling, pulling sensation with an irresistible need to move rather than a sharp, seizing pain, iron levels are worth investigating.

Getting the Right Nutrients From Food

If you suspect a deficiency is behind your cramps, food sources are the first line of action, with one important caveat about supplement quality. Not all forms of a mineral are absorbed equally. Magnesium citrate and magnesium chloride are well absorbed, while magnesium oxide (the most common and cheapest supplement form, and the one tested in the leg cramp trial above) has poor bioavailability due to low water solubility. Similarly, potassium citrate and potassium chloride are both well absorbed.

For magnesium, the richest food sources include pumpkin seeds, almonds, spinach, and black beans. For potassium, bananas get all the credit, but a medium baked potato, a cup of cooked lentils, or a serving of dried apricots all deliver more potassium per serving. Vitamin D comes from sun exposure, fatty fish, and fortified dairy. B12 is found almost exclusively in animal products: meat, fish, eggs, and dairy. Vitamin K2 is concentrated in fermented foods like natto, hard cheeses, and egg yolks.

How Quickly Supplements Help

Timeline matters when you’re dealing with nightly cramps. The vitamin K2 trial saw statistically significant improvement within the first week of daily supplementation. Correcting a vitamin D deficiency takes longer, typically several weeks to months, because your body needs time to rebuild its stores and reverse the nerve changes in muscle tissue. B12 repletion also takes weeks to months, depending on how depleted you are and whether the deficiency has caused nerve damage. If you’re supplementing and seeing no change after two to three months, the cramps likely have a different cause, whether that’s dehydration, medication side effects, or a circulation issue rather than a vitamin deficiency.