Muscle cramps are driven largely by what’s happening inside your cells, and the minerals you eat play a direct role. Potassium, magnesium, sodium, and calcium all help your muscles contract and relax properly. When any of these runs low, your muscle fibers become hyperexcitable and can lock into painful spasms. The good news is that a few targeted additions to your diet can make a real difference.
Why Minerals Control Your Muscles
Every time a muscle contracts, calcium floods into the muscle cell and triggers the fibers to slide together and shorten. When contraction is finished, magnesium and potassium help the cell relax and reset. Sodium, meanwhile, controls the electrical signals that tell the muscle to fire in the first place. If any of these minerals drops too low, the signaling goes haywire. Your nerves become too easily triggered, and instead of a smooth contraction followed by relaxation, you get a sustained, involuntary spasm.
This is why cramps tend to strike after heavy sweating, during long workouts, or overnight when you haven’t eaten or hydrated in hours. You’re not just losing water. You’re losing the dissolved minerals that keep your muscles functioning normally.
Potassium-Rich Foods
Potassium is probably the first mineral people think of when cramps come up, and for good reason. It regulates the electrical charge across muscle cell membranes, and even a mild deficit can leave muscles twitchy and prone to spasms. Adults need roughly 2,600 to 3,400 mg per day, and most people fall short.
Bananas get all the attention, but they’re actually a middleweight source at about 420 mg each. Better options include baked potatoes with the skin on, sweet potatoes, white beans, lentils, dried apricots, avocados, and cooked spinach. A single cup of cooked white beans delivers over 1,000 mg. Coconut water is another easy source, packing around 600 mg per cup. If you’re cramping regularly, adding one or two of these foods daily can meaningfully close the gap.
Magnesium-Rich Foods
Magnesium works as a natural muscle relaxant. After calcium triggers a contraction, magnesium helps the muscle release. Low magnesium is one of the most common nutritional deficiencies in adults, and muscle cramps and spasms are a hallmark symptom.
Seeds and nuts are the most concentrated food sources. A single ounce of pumpkin seeds delivers 156 mg of magnesium, nearly 40% of most adults’ daily needs. Other strong options, per serving:
- Chia seeds (1 oz): 111 mg
- Almonds (1 oz): 80 mg
- Cooked spinach (½ cup): 78 mg
- Cashews (1 oz): 74 mg
- Black beans (½ cup): 60 mg
- Edamame (½ cup): 50 mg
- Peanut butter (2 tbsp): 49 mg
- Brown rice (½ cup): 42 mg
Whole grains, dark leafy greens, and legumes round out the list. A practical approach: toss pumpkin seeds on a salad, snack on almonds, and swap white rice for brown. These small changes add up quickly.
Sodium and Hydration
Sodium gets a bad reputation in most nutrition conversations, but it’s essential for muscle function, especially if you sweat heavily. When you lose sodium through sweat faster than you replace it, your muscles are more likely to cramp. This is why plain water sometimes isn’t enough during intense or prolonged exercise.
Sports drinks formulated with sodium and other salts exist specifically for this reason. If you’re exercising hard for more than an hour, or you’re a heavy sweater, choosing a drink that contains sodium rather than plain water can help. Outside of exercise, most people get plenty of sodium from food. Pickles, olives, broth, and salted nuts are all easy sources. The goal isn’t to overdo sodium intake but to make sure you’re replacing what you lose.
Calcium From Everyday Foods
Calcium is the trigger that starts every muscle contraction. Without enough of it, the signaling between nerves and muscles becomes erratic. Dairy products like yogurt, milk, and cheese are the most familiar sources, but fortified plant milks, canned sardines and salmon (eaten with bones), tofu made with calcium sulfate, and cooked kale all contribute. Adults generally need around 1,000 mg per day. An 8-ounce glass of milk or fortified plant milk provides roughly 300 mg, so three servings of calcium-rich foods daily typically covers the requirement.
The Pickle Juice Effect
Pickle juice has become a popular cramp remedy among athletes, and there’s research behind it. A study published in Medicine and Science in Sports and Exercise found that a small amount of pickle juice (about 2.5 ounces for a 165-pound person) stopped electrically induced cramps roughly 45% faster than drinking nothing. The interesting part: the effect happened too quickly to be explained by the body absorbing the liquid and its electrolytes. Researchers believe the strong vinegar taste triggers a reflex in the mouth and throat that tells the nervous system to shut down the overactive nerve signals causing the cramp. So pickle juice works more like a nerve signal disruptor than a mineral supplement.
B Vitamins and Nighttime Cramps
If your cramps tend to strike at night, vitamin B12 is worth looking into. B12 supports nerve function, and a deficiency can cause the nerves controlling your muscles to misfire. In one clinical case documented in the journal Neurology, a patient with severe nocturnal leg spasms and confirmed B12 deficiency experienced complete resolution of cramps within four weeks of correcting the deficiency.
B12 is found naturally in animal products: meat, fish, eggs, and dairy. If you eat a plant-based diet, fortified cereals, nutritional yeast, and fortified plant milks are your main dietary sources. Vitamin D deficiency was also noted alongside B12 deficiency in that same case, so getting enough of both matters for muscle health. Fatty fish like salmon and mackerel, egg yolks, and fortified foods provide vitamin D.
Omega-3s for Menstrual Cramps
Menstrual cramps have a different mechanism than muscle cramps. They’re caused by hormone-like compounds called prostaglandins that make the uterus contract to shed its lining. Higher prostaglandin levels mean stronger, more painful contractions. Omega-3 fatty acids appear to counteract this process. A meta-analysis of 12 studies found that omega-3 intake had a large effect on reducing menstrual pain severity compared to placebo groups.
The best food sources of omega-3s are fatty fish (salmon, sardines, mackerel, herring), walnuts, flaxseeds, and chia seeds. Eating fatty fish two to three times per week, or adding a daily tablespoon of ground flaxseed to meals, provides a meaningful dose. If your period cramps are a primary concern, consistently eating these foods throughout your cycle is more effective than loading up the day symptoms start.
When and How to Eat These Foods
Timing matters most for exercise-related cramps. Eating an electrolyte-rich meal or snack 30 to 60 minutes before a workout gives your body time to start absorbing the minerals. A banana with peanut butter, a handful of salted almonds, or yogurt with pumpkin seeds all deliver a combination of potassium, magnesium, and sodium in that window. During exercise lasting longer than an hour, sipping a sodium-containing sports drink helps replace what you’re sweating out in real time.
For nighttime cramps, what you eat throughout the day matters more than any single pre-bed snack. Consistently hitting your daily targets for potassium, magnesium, and calcium keeps your baseline mineral levels stable. That said, a small magnesium-rich snack before bed, like a handful of cashews or a glass of milk, gives your body something to work with during the hours you’re fasting overnight.
For people who cramp frequently despite eating well, it’s worth noting that certain medications (diuretics, some blood pressure drugs) and conditions (kidney issues, heavy chronic sweating) can deplete electrolytes faster than food alone can replace them. In those situations, the problem isn’t what you’re eating but how quickly your body is losing what you take in.

