What to Eat for Cramps in Legs: Foods That Help

Leg cramps are closely tied to what you eat and drink, because the minerals that control muscle contraction and relaxation come directly from your diet. The four key players are magnesium, potassium, calcium, and sodium. When any of these runs low, your muscles are more likely to seize up, especially at night. The good news is that a few simple dietary shifts can make a real difference.

Why Minerals Matter for Muscle Cramps

Your muscles rely on a precise balance of electrolytes to contract and then relax again. Potassium supports nerve and muscle function, while magnesium helps muscles release after tightening. Calcium plays a role in how your nervous system sends signals to muscles, and sodium controls fluid levels that keep the whole system working smoothly. When you’re low on any of these, the “relax” signal can misfire, and the muscle locks up instead of releasing.

Most people who get frequent leg cramps aren’t severely deficient in one mineral. They’re just running a little low across the board, often from not eating enough whole foods, sweating heavily, or not drinking enough water.

Potassium-Rich Foods to Prioritize

Potassium is probably the mineral most people associate with cramps, and for good reason. It’s essential for both nerve signaling and muscle function. Adults need roughly 2,600 to 3,400 mg per day, and many people fall short.

Some of the best food sources, with potassium per serving:

  • Mung beans: 938 mg per cup
  • Baked potato: 583 mg per half potato
  • Banana: 519 mg per medium fruit
  • Raw baby spinach: 454 mg per cup
  • Dried apricots: 453 mg per 30 grams (about 5 pieces)
  • Cooked salmon: 380 mg per 100 grams
  • Milk: 377 mg per cup
  • Butternut pumpkin (baked): 332 mg per half cup
  • Chicken breast: 256 mg per serving
  • Canned tuna: 250 mg per 100 grams

Bananas get all the attention, but potatoes, beans, and leafy greens actually deliver more potassium per serving. Root vegetables, dried fruits, tomatoes, zucchini, and legumes like chickpeas are all solid choices. Yogurt, milk, and even chocolate and coffee contain meaningful amounts too.

Where to Get Enough Magnesium

Magnesium is the other mineral most directly linked to cramps. The recommended daily intake is 400 to 420 mg for adult men and 310 to 320 mg for adult women. During pregnancy, the target rises to 350 to 360 mg. Many adults fall 100 mg or more below these targets.

The richest food sources of magnesium include pumpkin seeds, almonds, cashews, dark chocolate, black beans, and whole grains like brown rice and oats. A quarter cup of pumpkin seeds alone delivers about 190 mg. Spinach is a double win, since it’s high in both magnesium and potassium. Adding a handful of nuts to a snack or swapping refined grains for whole grains at one meal can close the gap for most people.

If you’re considering a magnesium supplement, the timing doesn’t matter for its effect on your body. Taking it in the morning or before bed works equally well. What matters more is consistency.

Calcium and Sodium Deserve Attention Too

Calcium supports the nerve signals that tell your muscles when to contract. Most adults need about 1,000 mg per day. Dairy products are the most concentrated source: a cup of milk or yogurt provides around 300 mg. Fortified plant milks, canned sardines (with bones), tofu made with calcium sulfate, and broccoli also contribute.

Sodium often gets overlooked because people worry about getting too much. But if you sweat a lot from exercise, hot weather, or physical labor, you can lose enough sodium to throw off your muscle function. In those situations, drinks with electrolytes (especially sodium) work better than plain water. For most people eating a typical diet, sodium intake is adequate without extra effort.

Vitamin B12 and Vitamin D Gaps

Mineral deficiencies aren’t the only nutritional cause of leg cramps. Low vitamin B12 and vitamin D levels can also trigger painful spasms, particularly at night. In one documented case published in the journal Neurology, a patient with deficiencies in both vitamins experienced months of painful calf and thigh spasms that resolved completely within four weeks of B12 supplementation.

Vitamin B12 comes from animal products: meat, fish, eggs, and dairy. If you eat a plant-based diet, fortified foods or a supplement are the main options. Vitamin D is harder to get from food alone. Fatty fish, egg yolks, and fortified milk provide some, but sunlight exposure is the body’s primary source. If you spend most of your time indoors or live in a northern climate, a deficiency is common and worth checking.

Drinks That Help and Drinks That Hurt

Staying hydrated is one of the simplest ways to prevent cramps. A good rule of thumb: if your urine is clear or light yellow, you’re drinking enough. Dark yellow urine usually means you need more fluids.

Water is the baseline, but when you’re sweating heavily, plain water may not be enough. Adding an electrolyte drink that contains sodium helps replace what you lose through sweat. This is especially relevant during exercise or in hot weather.

On the other side, heavy caffeine intake can make cramps worse. Caffeine stimulates muscles directly, and in high amounts, it can make them more likely to seize. A cup or two of coffee isn’t the issue. The problem comes with multiple caffeinated drinks throughout the day, or energy drinks that pack much higher concentrations. Alcohol is another contributor, because it dehydrates the body and can deplete minerals over time.

Pickle Juice for Quick Relief

If you’ve heard that pickle juice stops cramps fast, there’s actually science behind it. Researchers at Michigan Medicine found that the acid in pickle brine triggers nerves in the back of the throat, which sends a signal that essentially switches the cramp off. This happens within seconds, far too quickly for any mineral to be absorbed. It’s a neurological reflex, not a nutritional fix. A small swig of pickle juice or even vinegar can work in the moment, but it won’t prevent cramps from coming back if your diet is the underlying issue.

Skip the Tonic Water

Tonic water contains quinine, a compound that has a long folk reputation for treating cramps. But the FDA has issued explicit warnings against using quinine for leg cramps. It’s only approved for treating malaria. When used for cramps, quinine carries risks of serious and potentially life-threatening side effects, including dangerous drops in blood platelet counts, severe allergic reactions, and heart rhythm problems. Fatalities have been reported. The small amount of quinine in commercial tonic water is unlikely to help with cramps, and treating it as a remedy can lead people toward higher, dangerous doses.

A Practical Eating Pattern for Cramp Prevention

You don’t need to overhaul your entire diet. A few targeted additions can cover the most common nutritional gaps behind leg cramps. Think of it as building a daily foundation:

  • Breakfast: Oatmeal with a banana and a handful of almonds covers magnesium and potassium early in the day.
  • Lunch: A salad with spinach, chickpeas, and pumpkin seeds adds both minerals plus some calcium.
  • Dinner: Salmon or chicken with a baked potato and roasted butternut squash delivers a strong potassium punch.
  • Snacks: Yogurt, dried apricots, or a small piece of dark chocolate fill in gaps between meals.

If you’re pregnant, the same foods apply, with extra attention to calcium (aim for 1,000 mg daily) and possibly a magnesium supplement. Staying well-hydrated matters even more during pregnancy, since blood volume increases significantly and fluid needs rise with it.

The pattern that prevents cramps is ultimately simple: eat whole foods from a variety of sources, drink enough water, go easy on caffeine and alcohol, and make sure you’re not skipping the mineral-rich foods your muscles depend on every time they contract and release.