What Vitamin Deficiencies Cause Muscle Cramps (and How to Treat Them)

Livestrong.com may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Cramps are involuntary muscle contractions that can be very painful.
Image Credit: KeremYucel/iStock/GettyImages

Cramps are involuntary muscle contractions, often in your legs. These unpleasant spasms are known for being unexpected and painful, and can be related to a wide range of different health issues, including a lack of certain nutrients. But what vitamin deficiency causes muscle cramps, exactly?


For context, cramping is common. February 2017 research in ​Family Practice​ found that more than 30 percent of older adults experience leg cramps. People assigned female at birth (AFAB) may be especially prone to cramping, per a June 2017 paper in ​PLOS One​. And between 30 and 45 percent of pregnant people will experience sleep-related leg cramps, according to an April 2015 report in ​Maternal and Child Nutrition​.

Video of the Day

Video of the Day

But it can still be difficult to tell what triggers cramps. Here are some common causes, per the Mayo Clinic:

  • Exercise, especially in hot weather
  • Dehydration
  • Pregnancy
  • Underlying conditions like diabetes or nerve, liver or thyroid disorders
  • Undergoing kidney dialysis
  • Side effect of medication
  • Aging, especially for people AFAB, per a November 2016 review in Age and Ageing

Mineral and vitamin deficiencies can also play a role in these painful muscle contractions, according to an August 2015 review in the Journal of Neurology. Here's what vitamin deficiencies cause cramps, how to deal with muscle spasms and the best vitamins and supplements for leg cramps.



Muscle cramps typically resolve on their own. But if cramps cause you extreme pain, happen frequently without an obvious cause or occur with other symptoms like muscle weakness, swelling or a change in skin color, visit your doctor, per the Mayo Clinic.

What Deficiencies Cause Leg or Muscle Cramps?

Knowing what vitamin deficiencies cause leg, foot or other muscle cramps may help you get to the root of your pain — here are some common culprits:

1. Vitamin B Deficiency

A vitamin B deficiency may contribute to muscle issues. For instance, not getting enough vitamin B1 can lead to cramping in your lower legs, according to October 2014 research in Neurologic Clinics.


Muscle cramps are likewise a symptom of vitamin B12 deficiency, per June 2019 research in Mayo Clinic Proceedings: Innovations, Quality & Outcomes.

2. Vitamin D Deficiency

Though the evidence is inconclusive, it's possible that a vitamin D deficiency can lead to muscle pain, according to June 2018 research in ​Bone Reports​.


A 2015 article in the International Journal for Vitamin and Nutrition Research showed that more than 60 percent of city-dwelling people had a vitamin D deficiency and that these people often had leg cramps. This finding suggests that treating the underlying deficiency might relieve the cramps, though more research is needed to establish this link.


3. Electrolyte Imbalance

Electrolyte imbalances can also be the cause of your muscle cramps, per the Mayo Clinic. This can occur when you lose too much fluid from excessive sweating, not drinking enough water, vomiting or diarrhea, according to the U.S. National Library of Medicine.


A lack of sodium is often to blame for electrolyte-induced cramping: Not having enough salt in your system can cause problems like muscle weakness, spasms and cramps, per the Mayo Clinic.

Magnesium can have a similar effect — not getting enough of this electrolyte can temporarily impair your muscle function and lead to spasms, weakness or stiffness, according to the Cleveland Clinic. The same goes for other electrolytes like potassium and calcium, both of which can lead to muscle cramping if your levels dip too low, per the Mayo Clinic.



Most electrolyte imbalances are temporary and can be resolved by hydrating and eating nutrient-rich foods. But if you notice symptoms like nausea, vomiting, confusion, seizures, or you lose consciousness, get medical care immediately, as you may be experiencing a severe sodium deficiency, per the Mayo Clinic.

How to Treat Muscle Cramps

Now that you know what vitamin deficiencies cause muscle cramps, here are some measures you can take to prevent or quell the pain.

1. Eat Vitamin-Rich Foods

Because vitamin deficiencies can cause muscle cramps, supplementing your diet with nutritious foods may help, per the Mayo Clinic.


For instance, load up on these sources of B vitamins for muscle cramp and spasm prevention:

  • Salmon
  • Spinach
  • Lentils
  • Chicken
  • Oranges
  • Avocados

Munching on vitamin D-rich foods may also help you steer clear of muscle pain, including:

  • Fish like trout, salmon and whitefish
  • Mushrooms
  • Soy products like fortified tofu and soy milk
  • Milk


You can also avoid electrolyte imbalances (and the muscle cramps they can bring) by eating foods containing electrolytes, such as:

  • Fish with bones, like sardines
  • Dairy products like milk and cheese
  • Olives
  • Greens like spinach, turnip greens, collard greens and kale
  • Potatoes and sweet potatoes
  • Fruit like bananas, oranges, avocados and melons
  • Legumes like lentils, peas and beans
  • Nuts

2. Stay Hydrated

If you're exercising, sweating, sick or otherwise losing a lot of bodily fluids, be sure to drink enough water to keep your electrolyte levels — especially sodium — in check, per the Mayo Clinic. Replenishing your electrolytes will help your muscle cells work their best so you can avoid uncomfortable cramping.

How Much Water Should You Drink?

Use this equation to determine how much water you should drink every day:

Body weight (in pounds) ÷ 2 = minimum ounces of water you should drink per day

3. Stretch

Stretching before and after physical activity may help prevent exercise-related muscle cramping, according to the Mayo Clinic.

If you regularly experience muscle cramps at night (or any other time), stretching or light activity before bed may help you avoid overnight aches, per the Mayo Clinic.

4. Massage the Area

Getting a massage in the affected area may help ease leg cramps, according to a January 2021 StatPearls article. This may be especially true for nighttime cramps, which are especially common in people age 60 and older.

Indeed, a September 2018 paper in ​BMC Musculoskeletal Disorders​ showed that foam rolling can relieve aches in your calves. Interestingly, you don't have to directly roll the irritated spot — just near it.

5. Try Trigger Point Therapy

Trigger points are tender spots of muscle that may underlie leg cramps, per an October 2016 review in Seminars in Neurology.


A January 2015 report in the Journal of the American Board of Family Medicine tested this hypothesis in people with weekly cramps and found that injecting lidocaine into calf trigger points decreased cramping and pain and even improved sleep.

What Is the Best Vitamin for Leg Cramps?

If your leg cramps are due to a nutrient deficiency and the above prevention and treatment methods aren't cutting it, here are some of the best vitamins and supplements for muscle cramps.

However, it's important to remember that the FDA does not require supplements to be proven safe or effective before they're sold, so there's no guarantee that any supplement you take is safe, contains the ingredients it says it does or produces the effects it claims.

As a result, talk with your doctor if you have frequent spasms to determine the best vitamins that help with muscle cramps.


Though you may have heard that vitamin E can help treat leg cramps at night, there's not much recent research to support this claim, per a May 2015 review in BMJ Clinical Evidence.

1. Vitamin B1

Taking B vitamins for cramps may help ease your pain, according to the ​Neurologic Clinics​ research. For instance, trying a vitamin B1 supplement can help prevent cramping if a deficiency is to blame.

However, visit your doctor before starting this supplement, as it's best to confirm you have a deficiency beforehand.

Products We Recommend

2. Vitamin B12

Vitamin B12 is another great supplement for leg cramps — especially if you follow a vegan diet, as most sources of B12 come from animal products, per the ​Neurologic Clinics​ research.

It's also best to talk to your doctor to determine the best supplement and dosage for you.


Products We Recommend

3. Vitamin D

If you're worried you're not getting enough vitamin D, talk to your doctor about whether a supplement may help you avoid associated issues like muscle pain, per the Mayo Clinic.

For example, people AFAB over the age of 51 may benefit from a supplement to help offset bone deterioration during and after menopause, per the 2020-2025 Dietary Guidelines for Americans.

That said, it's always ideal to get the bulk of your nutrients from whole foods, so aim to eat more natural sources of the vitamin before turning to vitamin D supplements.

Products We Recommend

4. Magnesium

Taking magnesium for leg cramps at night or during exercise may help prevent or reduce your pain, according to the Cleveland Clinic. Typically, replenishing electrolytes through proper hydration and nutrition is enough, but sometimes it may be helpful to take a supplement if you have a full-blown deficiency.

However, a May 2017 study in JAMA Internal Medicine failed to find any difference between the essential mineral and a placebo among a broad range of adults. And the ​Maternal and Child Nutrition​ research showed that magnesium might be effective only in specific populations, like pregnant people.

Accordingly, talk to your doctor to determine if you should take a supplement and if so, what magnesium is best for your leg cramps.

Products We Recommend

5. Potassium

Similarly, getting enough potassium from good hydration, nutrition and potentially a supplement can help keep your electrolyte balance stable, per the Mayo Clinic.

Products We Recommend

6. Calcium

The same goes for calcium, according to the Mayo Clinic. This is especially true for people AFAB over the age of 51, who need more calcium to combat age-related bone loss and may benefit from a supplement, per the Dietary Guidelines for Americans.

Products We Recommend




Is this an emergency? If you are experiencing serious medical symptoms, please see the National Library of Medicine’s list of signs you need emergency medical attention or call 911.

Report an Issue

screenshot of the current page

Screenshot loading...