What to Eat for Muscle Cramps: Key Nutrients

Muscle cramps are driven by how your nerves fire, and the foods you eat directly influence that process. The nutrients that matter most are magnesium, potassium, calcium, sodium, and B vitamins, all of which help regulate the electrical signals between your nerves and muscles. Getting enough of these through your diet can reduce how often cramps strike and how intense they feel.

Potassium-Rich Foods

Potassium helps maintain the electrical charge across muscle cell membranes. When levels drop, especially after sweating, muscles become more excitable and prone to involuntary contractions. The daily adequate intake is 2,600 mg for women and 3,400 mg for men, and most people fall short.

The best food sources per serving include bananas (about 420 mg each), but they’re far from the top of the list. Baked potatoes with skin deliver roughly 900 mg. A cup of cooked spinach provides around 840 mg. Sweet potatoes, white beans, and avocados all pack 500 mg or more per serving. Coconut water and orange juice are good liquid options if you want potassium during or after a workout. The key is eating these foods consistently, not just when a cramp hits.

Magnesium-Rich Foods

Magnesium acts as a natural muscle relaxant. It counterbalances calcium, which triggers contraction, so when magnesium is low, muscles can stay in a contracted state longer than they should. This is one of the most common nutritional gaps linked to cramping.

Dark chocolate (64 mg per ounce), almonds (80 mg per ounce), pumpkin seeds (150 mg per ounce), and black beans (120 mg per cooked cup) are all excellent sources. Leafy greens like Swiss chard and spinach are also rich in magnesium. Whole grains, dried fruits, nuts, and seeds round out the list. For pregnant women, who are especially prone to nighttime leg cramps, the Mayo Clinic specifically recommends eating more magnesium-rich foods like whole grains, beans, dried fruits, nuts, and seeds.

Calcium Beyond Dairy

Calcium plays a direct role in muscle contraction. Your muscles need it to contract properly, and without enough, the signaling between nerves and muscles becomes unreliable. While dairy is the most obvious source, plenty of non-dairy options work just as well.

Canned sardines and salmon (eaten with bones) are surprisingly high in calcium. Tofu made with calcium sulfate, fortified plant milks, edamame, leafy greens like collard greens, kale, bok choy, and turnip greens are all solid choices. Calcium-fortified orange juice and winter squash also contribute meaningful amounts. If you eat dairy, yogurt and cheese are efficient sources, with a cup of yogurt providing about 300 mg toward the roughly 1,000 mg daily goal.

Sodium and Salty Foods During Exercise

The relationship between sodium and cramps is more complicated than most people think. The old theory that sodium loss through sweat causes cramps hasn’t held up well under scientific scrutiny. Research has shown that dehydration and sodium depletion alone don’t adequately explain why cramps happen. That said, sodium still plays a supporting role in muscle function and fluid balance, and the American College of Sports Medicine recommends 300 to 600 mg per hour during prolonged exercise for general performance.

If you’re exercising for more than an hour, especially in heat, salty snacks like pretzels, salted nuts, or broth can help maintain electrolyte balance. Sports drinks with sodium work too. But loading up on salt specifically to prevent cramps isn’t backed by strong evidence. Think of sodium as one piece of the puzzle rather than a fix on its own.

Pickle Juice for Quick Relief

Pickle juice has a real physiological effect on cramps, but not for the reason most people assume. It’s not about replacing electrolytes. The acetic acid in pickle juice stimulates receptors in the back of your throat, triggering a reflex in the nervous system that increases inhibitory signals to the cramping muscle. Essentially, it tells your nerves to calm down.

In one study, swishing pickle juice in the mouth (without even swallowing) reduced cramp duration to about 69% of what it was with water alone. Drinking it brought cramp duration down to about 83% of the control. The differences weren’t statistically significant in that particular trial, but the neurological mechanism is well-documented. A small shot of pickle juice, roughly 1 to 2 ounces, is the typical amount people use. Mustard works on a similar principle because of its acetic acid content.

B Vitamins and Nerve Function

B vitamins, particularly B1, B6, and B12, support the nerve pathways that control muscle contraction. A small randomized trial of 28 older adults found that daily B-complex supplementation led to cramp remission in 86% of participants over 12 weeks, compared to no improvement in the control group. The study had limitations, but it points to a real connection between B-vitamin status and cramping frequency, especially in older adults who may not absorb these vitamins as efficiently.

You can get B vitamins from eggs, poultry, fish, legumes, fortified cereals, and nutritional yeast. Vitamin B12 comes almost exclusively from animal products or fortified foods, so people eating plant-based diets should pay extra attention to this one.

Watermelon and Muscle Recovery

Watermelon contains a compound called citrulline that your body converts into arginine, which then boosts nitric oxide production. Nitric oxide relaxes blood vessels and improves blood flow to muscles. A 500 mL serving of natural watermelon juice contains about 1.17 grams of citrulline. Research on athletes found that watermelon juice helped reduce muscle soreness after intense exercise, likely through its antioxidant properties and its role in improving circulation.

While watermelon won’t stop an active cramp, it’s a useful recovery food that also delivers water, potassium, and natural sugars. Eating it after exercise or as part of regular meals adds hydration alongside nutrients that support muscle health.

When and How to Eat for Cramp Prevention

Timing matters, particularly around exercise. Carbohydrate depletion contributes to cramping, so eating a carb-rich meal 3 to 4 hours before intense activity gives your muscles the fuel they need. If exercise lasts longer than 60 minutes, consuming carbohydrates during the session helps prevent depletion. High-potassium and salty foods are most useful during and after exercise, when your body is actively losing electrolytes through sweat.

For people who get cramps at night or at rest, the strategy shifts to overall dietary patterns rather than pre-workout timing. Eating a variety of the foods listed above throughout the day keeps your electrolyte and mineral levels steady. A handful of almonds as a snack, a baked potato at dinner, a glass of fortified orange juice in the morning: these small habits are more effective than trying to correct a deficiency after a cramp has already started. Chronic or severe cramping that doesn’t respond to dietary changes can signal an underlying issue worth investigating with a healthcare provider.