Key takeaways:
Muscle cramps are sudden, involuntary muscle contractions that can be painful.
Athletes, older adults, and people who are pregnant are more likely to experience muscle cramps. But they can happen to anybody, and without a clear cause.
Muscle cramps can be caused by muscle fatigue, dehydration, certain medical conditions, and some medications. Electrolyte imbalance can also play a role.
No particular food is proven to prevent cramps. But staying hydrated and getting enough sodium, potassium, magnesium, and calcium supports normal muscle function.
You’re drifting off to sleep, when suddenly you wake up with a seizing feeling in your calf muscle. Most people will experience a painful cramp at some point in their lives.
Muscle cramps feel like an intense, involuntary contraction in a specific area of the body — often the legs. Many people say it feels like the muscle is “knotting up” or tightening.
Muscle cramps can be painful. But they aren’t dangerous, and they usually resolve after a few minutes. Massaging the area can help the muscle to stop contracting. Once the cramp is over, the muscle may still feel sore for a while.
What causes muscle cramps?
Many factors can contribute to muscle cramping. Below are some of the more common causes.
Dehydration and electrolyte imbalance
When your body loses fluids, it also loses key electrolytes, such as:
Your muscles rely on these electrolytes for normal muscle contraction and relaxation. So significant changes in fluid or electrolyte levels can interfere with normal muscle function and may contribute to cramping.
Dehydration and electrolyte loss aren’t always obvious. They can be caused by:
Excessive sweating
Prolonged exposure to a hot environment, even without obvious sweating
Vomiting
Medications, like diuretics
Increased urination from health conditions, like diabetes
Tired muscles
Overworking your muscles can cause the communication between your nervous system and muscles to go into overdrive. Muscle cramps often happen during or after intense exercise. But they also sometimes happen at night during sleep. Stretching before and after exercise, massage therapy, and rest may help.
It‘s also important to note that age-related changes in muscles and nerves may make older adults more prone to cramps. This is partly why muscle cramps are more common in people over age 50. Older adults may also be more prone to dehydration.
Nutritional deficiencies
Electrolytes aren’t the only nutrients that play a role in muscle contraction. Certain nutrient deficiencies can affect nerve or muscle function and may contribute to cramps. Examples include:
Thiamin (vitamin B1)
Read more like this
Explore these related articles, suggested for readers like you.
Most people who eat a balanced diet get enough of these vitamins. But people with medical conditions that affect their nutritional intake or intestinal absorption may be at risk for deficiencies.
Health conditions
Certain health conditions and life stages may increase your risk of having muscle cramps, including:
Heart conditions, like coronary heart disease
High blood pressure
Neurological conditions, like Parkinson’s disease
Diabetes
These conditions may contribute to muscle cramps by affecting circulation, nerve function, or fluid and electrolyte balance. Some medications used to treat them can also increase the risk of cramping.
Foods that help with muscle cramps
The following foods provide the vitamins and minerals — and, in some cases, hydration — that may help with muscle cramps. It’s important to note that there isn’t a lot of research on how individual foods directly impact muscle cramps. So we chose foods that are rich in the electrolytes and other nutrients involved in muscle contraction and relaxation.
1. Avocados
Avocados are an excellent source of potassium, which works alongside other electrolytes to maintain your body’s fluid balance. Potassium also plays a role in helping your muscles contract and relax properly.
One medium Hass avocado has 1,000 mg of potassium, which is over 20% of the recommended Daily Value (DV). Avocados also contain the electrolyte magnesium.
Adding avocado to a salad or spreading it on a slice of toast is a great way to get these healthy nutrients.
2. Bananas
A medium banana contains about 420 mg of potassium (12% DV). This is less potassium than some foods. But bananas also contain magnesium, another mineral involved in muscle function.
Bananas are also a good source of carbohydrates, your body’s main source of energy during exercise. Your muscles store carbohydrates as glycogen and use this stored fuel during physical activity.
This combination of nutrients makes bananas a convenient post-exercise snack. But bananas alone may not be enough to correct a significant potassium deficiency or replace all the fluids and electrolytes lost during exercise.
3. Lentils and beans
Lentils and beans contain magnesium, an important electrolyte that helps your muscles properly contract and relax. Magnesium may also help reduce inflammation in your muscles after exercise.
Incorporating beans and lentils into your diet is as simple as tossing some into a salad. You can also add them to a casserole or soup.
4. Sweet potatoes
Sweet potatoes are an excellent source of potassium, calcium, and magnesium.
Sweet potatoes also contain antioxidants, including vitamin C and beta-carotene, that help prevent cell damage and fight inflammation.
Toss roasted sweet potatoes with broccoli and carrots for a tasty side dish. Or puree them and mix them into your morning oatmeal, pancake batter, or smoothie.
5. Melon
Melon contains electrolytes that can support hydration and normal muscle function. It’s also high in water, which can help you stay hydrated. Both cantaloupe and watermelon are about 90% water. Melon also provides vitamin C.
Add watermelon or cantaloupe cubes to your salad or morning smoothie. Or serve them alongside a scoop of cottage cheese or Greek yogurt for a protein-filled snack.
6. Leafy greens
Eating leafy greens is a great way to ensure you get various nutrients in your diet, particularly magnesium.
You can choose from a variety of leafy greens for your meals. Many leafy greens provide magnesium, potassium, and calcium.
Per 1 cup, cooked | Magnesium | Potassium | Calcium |
157 mg magnesium (37% DV) | 839 mg potassium (18% DV) | 245 mg calcium (19% DV) | |
150 mg magnesium (36% DV) | 961 mg potassium (20% DV) | 102 mg calcium (8% DV) | |
98 mg magnesium (23% DV) | 1,310 mg potassium (28% DV) | 164 mg calcium (13% DV) |
An added bonus is that leafy greens are low in calories and fiber rich. Add some to your salads or a sandwich, or blend them into your morning smoothie.
7. Yogurt and milk
Dairy products contain potassium and calcium. Dairy is also a great source of protein, which can help repair muscle tissue after exercise. Drinking a glass of milk after heavy exercise is often recommended to help with muscle recovery. Milk also helps with hydration.
8. Bone broth
Bone broth is hydrating, and it provides amino acids that are important for muscle health.
It also usually contains sodium, which may help replace some of the salt lost through sweat. But its mineral content varies depending on how it’s prepared.
You can use bone broth as a base for soups or to cook rice or other grains. Some people even drink it like tea.
9. Seafood
Seafood can be a great source of beneficial nutrients for muscle health. In particular, salmon, trout, and sardines are rich in:
Protein
B vitamins
Potassium
Seafood also contains omega-3 fatty acids, which may help reduce inflammation in muscles after exercise.
Most health organizations recommend eating 2 servings of seafood a week. Enjoy grilled salmon for dinner, eat a pouch of tuna after a workout, or add cooked shrimp to a stir-fry or soup.
10. Pickles
Some athletes drink pickle juice as a way to replenish their fluids and electrolytes after intense workouts. This is because pickle juice contains both water and sodium.
But most people usually only drink a small amount of pickle juice. For this reason, it may not meaningfully replace fluids or electrolytes. In a small study of adults, drinking pickle juice didn’t significantly affect sodium (or potassium) concentration during or after exercise.
Adding a few pickle slices to your sandwich can add sodium to a meal. But most people already get enough sodium — and extra sodium isn’t needed for routine muscle recovery.
Frequently asked questions
High potassium in the blood (hyperkalemia) doesn’t usually cause leg cramps. In fact, high potassium often causes no noticeable symptoms — even though it can be a medical emergency. It’s typically only discovered through a blood test. Low potassium (hypokalemia) is much more likely to cause leg cramps. That’s because potassium helps your nerves and muscles work properly. When potassium levels drop too low, it can disrupt muscle signals, leading to weakness, twitching, or cramps in the leg.
Mustard is a popular home remedy for leg cramps, but there isn’t research to show that it works. One theory is that mustard’s strong, spicy taste can stimulate nerves in the mouth and throat, calming the nerve signals involved in a cramp. But this hasn’t been proven. And mustard doesn’t contain enough electrolytes or fluid to correct dehydration or an electrolyte imbalance quickly.
No foods directly cause leg cramps at night. But certain eating patterns may make leg cramps more likely. Diets high in sodium, refined grains, and alcohol can raise your risk of leg cramps when they replace more nutritious foods. To lower your risk of leg cramps and support healthy muscles, try to choose foods rich in magnesium, calcium, and potassium.
High potassium in the blood (hyperkalemia) doesn’t usually cause leg cramps. In fact, high potassium often causes no noticeable symptoms — even though it can be a medical emergency. It’s typically only discovered through a blood test. Low potassium (hypokalemia) is much more likely to cause leg cramps. That’s because potassium helps your nerves and muscles work properly. When potassium levels drop too low, it can disrupt muscle signals, leading to weakness, twitching, or cramps in the leg.
Mustard is a popular home remedy for leg cramps, but there isn’t research to show that it works. One theory is that mustard’s strong, spicy taste can stimulate nerves in the mouth and throat, calming the nerve signals involved in a cramp. But this hasn’t been proven. And mustard doesn’t contain enough electrolytes or fluid to correct dehydration or an electrolyte imbalance quickly.
No foods directly cause leg cramps at night. But certain eating patterns may make leg cramps more likely. Diets high in sodium, refined grains, and alcohol can raise your risk of leg cramps when they replace more nutritious foods. To lower your risk of leg cramps and support healthy muscles, try to choose foods rich in magnesium, calcium, and potassium.
The bottom line
No particular food is a magic fix for muscle cramps. But a balanced diet that provides potassium, magnesium, calcium, and other nutrients can help keep your muscles working smoothly. Staying hydrated may also help, especially during intense exercise or hot weather. And when a pesky muscle cramp strikes, gentle stretching or massaging may help you find relief.
Why trust our experts?



References
American Heart Association. (2024). Fish and omega-3 fatty acids.
American Pregnancy Association. (2026). Leg cramps during pregnancy.
Bordoni, B., et al. (2023). Muscle cramps. StatPearls.
Grandner, M. A., et al. (2017). Nocturnal leg cramps: Prevalence and associations with demographics, sleep disturbance symptoms, medical conditions, and cardiometabolic risk factors. PLOS One.
Gröber, U., et al. (2015). Magnesium in prevention and therapy. Nutrients.
Jahic, D., et al. (2018). Exercise-associated muscle cramp-doubts about the cause. Materia Socio Medica.
Jouris, K. B., et al. (2011). The effect of omega-3 fatty acid supplementation on the inflammatory response to eccentric strength exercise. Journal of Sports Science and Medicine.
McKenney, M. A., et al. (2015). Plasma and electrolyte changes in exercising humans after ingestion of multiple boluses of pickle juice. Journal of Athletic Training.
Miller, K. C., et al. (2012). Plasma potassium concentration and content changes after banana ingestion in exercised men. Journal of Athletic Training.
Murray, B., et al. (2018). Fundamentals of glycogen metabolism for coaches and athletes. Nutrition Reviews.
MyFoodData. (n.d.). Cooked beet greens (boiled, drained).
MyFoodData. (n.d.). Cooked spinach chard (boiled, drained).
MyFoodData. (n.d.). Cooked Swiss chard (boiled, drained).
MyFoodData. (n.d.). Wellsley Farms - Hass avocados, Hass.
National Institutes of Health. (2023). Thiamin.
Souza, A. C. R., et al. (2023). The integral role of magnesium in muscle integrity and aging: A comprehensive review. Nutrients.
U.S. Department of Agriculture. (2019). Bananas, raw.
U.S. Department of Agriculture. (2019). Fish, salmon, Atlantic, wild, raw.
U.S. Department of Agriculture. (2019). Fish, sardine, Atlantic, canned in oil, drained solids with bone.
U.S. Department of Agriculture. (2019). Fish, trout, rainbow, farmed, raw.
Young, G. (2015). Leg cramps. British Medical Journal Clinical Evidence.















