How to Avoid Leg Cramps: Stretching, Hydration & More

Most leg cramps can be prevented with a combination of regular stretching, adequate hydration, and attention to your electrolyte intake. The cramps themselves are involuntary muscle contractions driven by misfiring nerve signals, and the strategies that work best target those signals at their source: fatigued muscles, dehydrated tissue, or mineral imbalances.

Why Leg Cramps Happen

Two competing theories explain most leg cramps, and both likely play a role depending on the situation. The first involves muscle fatigue. When a muscle is overworked, the balance between nerve signals that excite the muscle and signals that tell it to relax gets disrupted. Excitatory signals from muscle spindles ramp up while inhibitory signals from tendon organs decrease, and the result is an involuntary contraction you can’t release.

The second theory involves fluid and electrolyte shifts. Heavy sweating without adequate fluid replacement raises the concentration of your extracellular fluid. This pulls water out of the spaces between cells, increasing pressure on nearby nerves and distorting their signaling. That’s why cramps are so common during intense exercise in hot conditions, and why people who only drink plain water sometimes cramp more than those who drink nothing at all. A study from Edith Cowan University found that rehydrating with plain water after dehydration actually made muscles more susceptible to cramping, while fluids containing electrolytes reversed that effect.

Stretch Before Bed and After Exercise

Stretching is the single most consistently recommended intervention for cramp prevention. For calf cramps, the classic wall stretch works well: stand facing a wall, place one foot behind you with the heel flat on the floor, and lean forward until you feel a pull in the back of your lower leg. Hold that position for 30 to 60 seconds, then switch sides. Do this before bed every night if you’re prone to nighttime cramps, and both before and after any exercise session.

The goal isn’t flexibility for its own sake. Stretching helps maintain the resting length of the muscle and reduces the kind of residual tension that can tip fatigued nerve pathways into a cramp. Consistency matters more than intensity here. A brief routine every evening is more effective than an aggressive session once a week.

Dial In Your Hydration

A useful baseline formula: multiply your body weight in pounds by 0.67 to get the number of ounces of water you need per day. Then add 12 ounces for every 30 minutes of exercise. A 150-pound person who exercises for an hour would need roughly 125 ounces daily.

Plain water is fine for everyday hydration, but if you’re exercising hard or sweating heavily, switch to a drink that contains sodium and potassium. The electrolyte balance matters. Sodium is the mineral you lose most through sweat, and potassium helps regulate the electrical signals that control muscle contraction. You don’t need a specific clinical formula. A sports drink, coconut water, or even water with a pinch of salt and a squeeze of citrus will get you closer to what your muscles need than water alone.

Eat for Your Muscles

Potassium, magnesium, and calcium all play roles in muscle contraction and relaxation. Most people can get enough from food without supplements. Bananas, potatoes, avocados, and beans are rich in potassium. Dark leafy greens, nuts, seeds, and whole grains supply magnesium. Dairy products and fortified plant milks cover calcium.

Magnesium supplements have been studied specifically for nocturnal leg cramps, with trials testing doses ranging from 300 to 360 mg of various forms including magnesium citrate and magnesium bisglycinate. The results have been mixed. A systematic review of randomized controlled trials found that magnesium supplementation did not consistently outperform placebo for reducing cramp frequency in the general population. That said, if your diet is genuinely low in magnesium (common in older adults and people who eat mostly processed food), bringing your levels up to normal can help. Magnesium citrate and bisglycinate tend to be better absorbed than cheaper oxide forms.

Set Up Your Sleep Environment

Nighttime leg cramps often strike the calves and feet, partly because of how we position ourselves during sleep. Pointing your toes downward (which happens naturally when you sleep on your stomach or under heavy blankets) keeps the calf muscle in a shortened position for hours, making it more cramp-prone. Two adjustments can help: if you sleep on your back, prop your toes up so your feet are at a neutral angle. If you sleep on your stomach, let your feet hang over the end of the mattress so your calves stay lengthened.

Keep a heating pad and a foam roller or tennis ball near your bed. If a cramp wakes you, flexing the affected foot (pulling your toes toward your shin) is the fastest way to break the spasm. Applying heat and massaging the muscle afterward helps relieve residual soreness. Walking around on your heels for a minute also forces the calf to stretch and can cut the cramp short.

Check Your Footwear

Shoes that lack arch support or force your foot into unnatural positions can contribute to chronic calf and foot cramps. If you spend long hours standing or walking, supportive shoes with adequate cushioning reduce the amount of compensatory work your lower leg muscles have to do. This is especially relevant if your cramps tend to hit after long days on your feet rather than during exercise.

The Pickle Juice Trick

Drinking a small amount of pickle juice can stop a cramp remarkably fast, often within about 35 seconds. The mechanism isn’t about replacing lost electrolytes (there isn’t enough time for digestion to play a role). Instead, researchers at Brigham Young University found that the acetic acid in pickle juice triggers a reflex in the mouth and throat that sends an inhibitory signal to the overactive nerve driving the cramp. In their study, cramp duration was about 49 seconds shorter with pickle juice compared to water. Any vinegar-based liquid likely works through the same mechanism, so mustard (which contains vinegar) produces a similar effect. This is a treatment for cramps in progress rather than a prevention strategy, but keeping a small bottle of pickle juice in the fridge gives you a fast option when one hits.

Medications That Cause Cramps

If your cramps started or worsened after beginning a new medication, the drug itself may be the problem. Diuretics (water pills) used for blood pressure are a common culprit because they flush potassium and magnesium out through your urine, directly depleting the minerals your muscles need. Cholesterol-lowering statins are another frequent offender. Muscle pain, soreness, and cramping are among the most common side effects reported by statin users. The discomfort ranges from mild to severe enough to interfere with daily activities.

If you suspect a medication is contributing to your cramps, that’s a conversation worth having with whoever prescribed it. Dose adjustments, switching to a different drug in the same class, or adding a mineral supplement can sometimes resolve the issue without stopping treatment.

Why Quinine Is Not the Answer

Quinine, found in tonic water and available as a prescription drug, was once widely used for leg cramps. The FDA has made clear that quinine is not considered safe or effective for this purpose. It carries risks of serious blood disorders, dangerous heart rhythm changes, kidney failure requiring dialysis, and death. Since 2006, the FDA has added a boxed warning (the strongest safety warning a drug can carry) and issued multiple alerts to discourage its off-label use for cramps. Tonic water contains much less quinine than a prescription dose, but it’s still not a recommended approach when safer alternatives exist.

A Simple Nightly Routine

If nighttime cramps are your main problem, a practical prevention routine takes about five minutes. Stretch both calves for 30 to 60 seconds each. Drink a glass of water (or an electrolyte drink if you exercised that day). Adjust your sleeping position so your feet aren’t pointed. Keep a heating pad within reach. Most people who do this consistently see a noticeable drop in cramp frequency within a few weeks.