How to Prevent Nighttime Leg Cramps: Stretches, Diet & More

Nighttime leg cramps can often be reduced or prevented through a combination of stretching, hydration, dietary adjustments, and simple changes to how you sleep. Most people experience these cramps in the calf, and while they’re rarely dangerous, they can seriously disrupt sleep. The good news is that several practical strategies have real evidence behind them.

Stretch Your Calves and Hamstrings Before Bed

Stretching is the most consistently recommended non-drug approach. In a randomized trial of 80 adults over 55, those who stretched their calves and hamstrings before bed had roughly 1.2 fewer cramps per night after six weeks compared to a control group. That’s a meaningful reduction for people waking up multiple times.

The key detail is timing: stretching right before bed appears more effective than spreading stretches throughout the day. A separate review found that stretching three times daily for 12 weeks didn’t reduce cramp frequency in older adults. The bedtime session seems to matter most, likely because it lengthens muscles that tend to shorten while you sleep. Hold each stretch for about 30 seconds. A classic wall lean for your calves and a seated toe-touch for your hamstrings are enough.

Keep Your Feet in a Neutral Position

When your feet point downward while you sleep, a position called plantar flexion, your calf muscles sit in a shortened state for hours. This makes them more prone to involuntary contractions. Sleeping on your back with heavy blankets pressing your feet down is a common trigger.

Loosening the sheets and blankets at the foot of your bed gives your feet room to stay upright. If you sleep on your back, placing a pillow under your calves or propping your feet against a footboard can help keep them closer to a right angle. Side sleepers can let their feet hang over the edge of the mattress. These are small adjustments, but they directly address one of the mechanical causes of nighttime cramps.

Stay Hydrated, but Include Electrolytes

Dehydration is one of the most common and overlooked cramp triggers. A practical formula from Mass General Brigham: multiply your body weight in pounds by 0.67 to get the number of ounces of water you should aim for each day. Add 12 ounces for every 30 minutes of exercise.

Plain water alone isn’t always enough. When you sweat or don’t eat enough mineral-rich foods, your levels of potassium and sodium can drop. Potassium is essential for communication between nerves and muscles. When levels fall too low, muscles can get stuck in a contracted state, which is exactly what a cramp is. Drinking large amounts of plain water without replacing sodium can actually dilute your blood sodium to dangerously low levels.

Potassium-rich foods to work into your diet include sweet potatoes, melon, cooked spinach, nuts, and beans. If you exercise heavily or sweat a lot during the day, a sports drink with sodium can help maintain electrolyte balance heading into the night.

Vitamin K2: A Newer Finding Worth Knowing

A recent randomized trial highlighted by the American Academy of Family Physicians found that vitamin K2 (specifically a form called menaquinone-7, taken at 180 micrograms in the evening) dramatically reduced nighttime cramps. Over two months, the treatment group averaged fewer than one cramp per week, while the placebo group climbed to more than 3.6 per week. That translated to more than 21 fewer cramp episodes over the study period. Improvements showed up within the first week and continued to widen over time. Duration and severity also appeared lower in the treatment group.

This is a relatively new finding and not yet part of standard guidelines, but the results were striking enough that it’s worth discussing with your doctor if cramps are a persistent problem.

The Truth About Magnesium

Magnesium is one of the most popular supplements people try for leg cramps, but the evidence is disappointing for most adults. A systematic review concluded that magnesium supplementation is unlikely to provide meaningful cramp prevention in older adults. Despite widespread belief and frequent recommendations, clinical trials have not shown consistent benefits for the general population.

Magnesium may still help if you have a genuine deficiency, which is more common in people who take certain medications, drink heavily, or have digestive conditions that impair absorption. But for the average person with nighttime cramps, magnesium supplements alone are unlikely to solve the problem.

B Vitamins May Help Some People

A small study published in Neurology found that a vitamin B complex (including 30 mg per day of vitamin B6) led to remission of muscle cramps in 86% of treated patients who weren’t known to be vitamin deficient. The American Academy of Neurology classifies B vitamins as “possibly effective” for cramps. The evidence is limited, but for people who haven’t responded to stretching and hydration changes, it’s a low-risk option to try.

Check Your Medications

Several common prescription and over-the-counter drugs list leg cramps as a side effect. The Cleveland Clinic identifies these categories as frequent culprits:

  • Diuretics (water pills), which deplete electrolytes
  • Statins (cholesterol-lowering drugs)
  • Certain antidepressants, including sertraline and fluoxetine
  • Sleep medications like zolpidem
  • Nerve pain medications like gabapentin and pregabalin
  • Some pain relievers like naproxen and celecoxib
  • Inhaled bronchodilators used for breathing conditions

If your cramps started or worsened after beginning a new medication, that connection is worth raising with your prescriber. Sometimes a dosage adjustment or alternative drug can make a significant difference.

Avoid Quinine for Cramps

Quinine, found in tonic water and available by prescription, was once widely used for leg cramps. The FDA has explicitly warned against this. Quinine is approved only for treating malaria and is not considered safe or effective for leg cramps. It carries serious risks including a dangerous drop in blood platelets, life-threatening allergic reactions, and heart rhythm disturbances. Fatalities and kidney failure requiring dialysis have been reported. Since 2006, the FDA has issued multiple warnings and added a boxed warning to quinine labeling about these hematologic risks. Drinking small amounts of tonic water is unlikely to cause harm, but using quinine therapeutically for cramps is a risk not worth taking.

Cramps vs. Restless Legs Syndrome

Nighttime leg cramps and restless legs syndrome both strike at night and involve the legs, but they’re quite different. Cramps are sudden, painful, involuntary muscle contractions, most often in the calf. You can usually feel or see the muscle locked in a hard knot, and the pain resolves when the contraction releases (though soreness can linger).

Restless legs syndrome is characterized by an uncomfortable urge to move your legs, not a painful contraction. It typically worsens at rest and in the evening, and moving the legs brings temporary relief. If your symptoms feel more like crawling, tingling, or an irresistible need to shift position rather than a sharp seizing pain, restless legs syndrome may be a better explanation, and it has different treatments.

Putting It All Together

Start with the basics: stretch your calves and hamstrings for 30 seconds each right before getting into bed, loosen the blankets around your feet, and make sure you’re drinking enough water with adequate electrolytes throughout the day. Review your medication list for known cramp-causing drugs. If cramps persist after several weeks of these changes, vitamin K2 and B-complex supplements are options with at least preliminary evidence. Skip the magnesium unless you have reason to think you’re deficient, and stay away from quinine entirely.