Do you know that moment during a workout when a muscle suddenly contracts and forces you to stop dead? Cramps are among the most common complaints among athletes, from beginners to experienced competitors. People often say that all you need to do is eat a banana or take magnesium. The reality is a little more nuanced, and that is precisely what helps prevent them more effectively. Here is an overview of what we really know, the role of each electrolyte, nighttime cramps, and the right things to do before, during, and after exercise.
What exactly is a muscle cramp?
A cramp is a sudden, painful, involuntary contraction of a muscle or group of muscles. It lasts from a few seconds to several minutes and mainly affects the calves, thighs, feet, or abdominal muscles.
It should not be confused with delayed-onset muscle soreness. A cramp occurs during or just after exercise, suddenly. Delayed-onset muscle soreness is a diffuse pain that appears 24 to 48 hours after a session, caused by minor damage to muscle fibers. The mechanisms are completely different, as are the solutions.
Why cramps occur during exercise
Two explanations that often overlap
Research now points to two main explanations. The first is neuromuscular fatigue: when a muscle is pushed beyond what it is trained for, the nerve signals controlling contraction go into overdrive, while the braking mechanism that should allow it to relax can no longer keep up. This is the best-supported explanation, and it accounts for why cramps so often occur at the end of a competition or during exertion that is more intense than usual.
The second is an imbalance in fluids and electrolytes. When you sweat heavily, you lose sodium, potassium, and some magnesium, minerals involved in nerve transmission and muscle contraction. The direct link between these losses and cramps is less clear in studies than is often suggested, but the two mechanisms are not mutually exclusive. An athlete who is tired and has sweated heavily in hot weather checks both boxes at the same time.
When they are most likely to occur
Exercise cramps occur mainly at the end of long sessions such as a marathon, trail race, or 90-minute match, in hot and humid weather, after a sudden increase in training intensity or volume, and when the diet is low in minerals. Sports with lots of accelerations, such as football, tennis, or basketball, are also particularly affected.
The role of each electrolyte in the muscle
Electrolytes are electrically charged minerals: sodium, potassium, magnesium, calcium, and chloride. With each contraction, an exchange of sodium and potassium on either side of the muscle cell membrane triggers the signal. Calcium initiates contraction, while magnesium then helps the muscle relax.
Sodium, the one you lose the most
Sodium is the mineral found in the greatest quantity in sweat, ranging from around 400 to more than 1,000 mg per liter depending on the person, the intensity, and the heat. It helps your body retain the water you drink and distribute it where it is needed. During long, very sweaty exercise, drinking large amounts of water without any sodium intake can eventually dilute the sodium in your blood. This is rare but real, and we discuss it in detail in our article on hyponatremia during running.
Potassium, at the heart of muscle excitability
Potassium contributes to the normal functioning of the nervous system and muscles. It is lost in smaller quantities than sodium through sweat, but a significant deficiency, known as hypokalemia, causes muscle weakness and sometimes cramps. Bananas are the best-known source, with around 370 mg per 100 g. This is a good foundation, but it is not always enough on its own after a demanding session.
Magnesium, the mineral of relaxation
Magnesium contributes to normal muscle function and the reduction of fatigue. In muscle cells, it acts as a counterbalance to calcium: calcium triggers contraction, while magnesium enables relaxation. It is also involved in more than 300 enzymatic reactions, including the production of ATP, the cells' energy source.
This is also a mineral whose intake is often slightly too low. The French SU.VI.MAX study showed that more than 70% of the adults monitored had intakes below the recommended levels, set at 375 mg per day in Europe. Athletes lose slightly more through sweat and urine.
These three minerals do not only manifest through cramps. Our article on the seven signs of an electrolyte deficiency reviews the other warning signs to look out for.
How to prevent cramps during exercise
Before exercise: arrive well prepared
Prevention starts during training. Gradually increasing the duration and intensity of your sessions is the most reliable way to prevent neuromuscular fatigue. For hydration, drink 400 to 600 ml of water in the two to three hours before an intense session. Water is enough in the vast majority of cases. If the session lasts more than an hour or it is very hot, you can add a source of electrolytes.
During exercise: drink regularly, without overdoing it
For exercise lasting more than 45 minutes, aim for around 150 to 200 ml every 15 to 20 minutes, adjusting for how much you sweat. During long or very hot sessions, a drink containing sodium helps replenish what you lose. To find out how much you really sweat, the simplest option is to do the weigh-in test.
After exercise: replenishing your reserves
Recovery begins as soon as your session ends. Drinking promptly and planning a meal rich in minerals helps replenish the water and electrolytes lost. We explain what to drink and when in our guide to recovery after exercise.
Our coconut water electrolyte drink is designed for this moment: 300 mg of potassium, 300 mg of sodium and 56 mg of magnesium per bottle, ready to drink. If you prefer to prepare it yourself, the recipe is in our article on homemade electrolyte drinks.
Foods that meet your daily needs
Food remains the primary source of minerals, well ahead of sports drinks. For magnesium, focus on pumpkin and sunflower seeds, almonds and cashews, dark chocolate with at least 70% cocoa, legumes such as lentils and chickpeas, whole grains, and leafy green vegetables such as spinach and Swiss chard.
Potassium is found in bananas, avocados, sweet potatoes, white beans, dried fruit and coconut water. Sodium is rarely a problem day to day, as it is already present in salt, bread, olives and aged cheeses.
A varied diet rich in plant-based foods covers most of your needs at rest. It is long efforts and high heat that require additional replenishment. Our electrolyte drinks guide sorts out the situations where they are genuinely useful from those where water is enough.
Nighttime cramps: a case apart
Cramps that wake you at night, especially in the calves, affect a large proportion of adults, whether they exercise or not. They most often occur during the second half of the night. Several factors can promote them: an unusually intense workout during the day, a sedentary lifestyle, insufficient hydration throughout the day, certain medications such as diuretics, or slightly inadequate magnesium intake.
A few simple habits often help: gently stretch your calves before going to bed, drink regularly throughout the day rather than a lot at once in the evening, and make sure you get enough magnesium through your diet. If you are considering supplementation, bisglycinate, citrate, and malate forms are better absorbed than oxide. Ask a doctor or pharmacist for advice before starting a course, especially if you are taking medication. The link between magnesium and sleep is explored in our article on magnesium and sleep.
If nighttime cramps are frequent, very painful, or occur with no connection to exercise, see your doctor to rule out another cause.
What to do when a cramp occurs
Gently stretch the affected muscle. For a calf cramp, pull your toes toward you while keeping your leg straight. Then massage the area to help the muscle relax, and a heat source may provide relief if the pain persists. Once the cramp has passed, reduce the intensity, drink fluids, and remember to replace the fluids and minerals lost if you have been sweating heavily.
To take your electrolytes everywhere, our electrolyte powder provides 252 mg of sodium, 300 mg of potassium, and 56 mg of magnesium per stick, with no sugar. If you want to compare them with other brands, the actual amounts are shown side by side on drinkscore.info.
Both formats, powder and ready-to-drink, are available in our electrolyte range.
FAQ: your questions about cramps, magnesium, and electrolytes
Why do I get cramps at night after exercising?
Most often, it is the combination of a more intense-than-usual workout and incomplete recovery, in terms of both fluids and minerals. Gentle stretching before bed, good hydration throughout the day, and a mineral-rich dinner often help. If they recur regularly, ask a doctor for advice.
Is drinking more water enough to prevent cramps?
Water remains the basis of hydration and is sufficient in most situations. During a long, very hot, or highly sweaty effort, adding sodium helps compensate for losses, and drinking very large amounts of plain water over several hours can even become counterproductive. The right approach is to adapt what you drink to how much you sweat.
How much magnesium per day to prevent cramps?
The reference value in Europe is 375 mg per day for an adult, which should first be obtained through food. Supplementation may be considered if intake is insufficient, ideally with a healthcare professional. Above 250 mg per day from supplements, the EFSA reports a risk of digestive side effects.
Does a banana really help with cramps?
A banana provides about 400 mg of potassium, making it a good snack for athletes. But it contains little magnesium and sodium, and a banana alone cannot compensate for a strenuous workout in hot weather. Varying your sources is more effective than relying on a miracle food.
Is stretching enough to prevent cramps?
Regular stretching and gradual training are among the most effective ways to prevent exercise cramps, as they act on neuromuscular fatigue. They do not replace proper hydration during long efforts. Both go hand in hand.
Can a cramp have a cause other than exercise?
Yes. Certain medications, neurological disorders, nerve compression, or circulatory problems can also cause them. If they are very frequent, severe, or occur at rest without any sporting context, it's best to consult a doctor.
What's the difference between a cramp and muscle soreness?
A cramp is a sudden, involuntary contraction that occurs during or just after exercise. Muscle soreness is a diffuse pain that appears one to two days after a workout, linked to small muscle fiber injuries. Hydration has no proven effect on muscle soreness.
In summary
Exercise cramps most often come from a muscle being pushed beyond its training level, sometimes made worse by heavy sweating. The best tools are gradual training, stretching, a diet rich in magnesium and potassium, and hydration adapted to how much you sweat: water in most cases, with added sodium during long, hot efforts. If the cramps return often or occur at rest, it's time to talk to a doctor.



