Muscle cramps are painful, involuntary muscle contractions. Research suggests that replacing certain nutrients like potassium, sodium, and magnesium may help reduce them.

Muscle cramps are typically brief and usually over within a few seconds to a few minutes (1, 2).

Although the exact cause isn’t always known, intense exercise, neuromuscular abnormalities, medical conditions, an electrolyte imbalance, medication use, and dehydration are thought to be common contributors (2).

Some research shows that replacing certain nutrients may help counteract muscle cramps. Plus, deficiencies in nutrients like magnesium, vitamin D, and certain B vitamins may increase the chances of muscle cramps (3, 4, 5).

Here are 12 foods that may help with muscle cramps.

Avocados are creamy, delicious fruits that are packed with nutrients that may help prevent muscle cramps.

They’re particularly rich in potassium and magnesium, two minerals that act as electrolytes in the body and play roles in muscle health. Electrolytes are electrically charged substances that your body needs to perform critical functions, including muscle contraction (6, 7).

When electrolytes become imbalanced, such as after intense physical activity, symptoms like muscle cramping can arise (3).

Therefore, if you experience frequent muscle cramps, making sure you consume plenty of electrolyte-rich foods like avocados may help.

One possible cause of muscle cramps is dehydration. Proper muscle function requires adequate hydration, and a lack of water can hinder muscle cells’ ability to contract, which may cause or exacerbate cramping (8).

Watermelon is a fruit that has an exceptionally high water content. In fact, watermelon is nearly 92% water, making it an excellent choice for a hydrating snack (9).

What’s more, watermelon is a good source of magnesium and potassium, two minerals that are important for overall muscular function.

Coconut water is a go-to choice for athletes looking to rehydrate and replenish electrolytes naturally — and for good reason.

It’s an excellent source of electrolytes, providing calcium, potassium, sodium, magnesium, and phosphorus — all of which may help decrease muscle cramping (10).

One study found that when 10 male athletes rehydrated with an electrolyte-containing beverage similar to coconut water after intense exercise, they were less susceptible to electrical-stimulation-induced muscle cramps, compared with when they hydrated with regular water (3).

This may indicate that staying hydrated with electrolyte-rich coconut water may help reduce your susceptibility to post-exercise muscle cramping, though more research is needed.

Sweet potatoes are amongst the healthiest vegetables you can eat due to the powerful combination of vitamins, minerals, and plant compounds found within their flesh and skin.

They’re packed with potassium, calcium, and magnesium — minerals that are vital for muscle function.

In fact, 1 cup (200 grams) of mashed sweet potato delivers over 20% of the recommended intake for potassium and nearly 13% of the recommended intake for magnesium (11).

Greek yogurt is a healthy dairy product that’s high in many nutrients, particularly potassium, phosphorus, and calcium — all of which act as electrolytes in your body.

Muscles need calcium to function properly, which is why a lack of calcium in your blood can lead to muscle-related complications, including muscle cramps and irregular heartbeat (12).

Greek yogurt is also loaded with protein, which is needed for the growth and repair of muscle tissue.

Therefore, eating Greek yogurt after a strenuous workout can help replenish certain nutrients that may prevent exercise-related muscle cramps, as well as boost muscle recovery (13).

Bone broth is made by simmering animal bones in water for a long time, usually over 8 hours, to create a concentrated broth. Ingredients like apple cider vinegar, herbs, and spices are typically added to enhance the nutritional value and flavor.

Bone broth may help reduce muscle cramps for several reasons. Given that it’s a liquid, drinking it can help you stay hydrated, which may reduce muscle cramping.

Plus, bone broth is a good source of magnesium, calcium, and sodium — nutrients that may help prevent cramping.

When making bone broth, be sure to cook the broth for a long time and add an acidic component, such as apple cider vinegar, to your recipe.

Research shows that reducing bone broth pH by increasing the acidity and cooking broth for longer than 8 hours results in significantly higher concentrations of calcium and magnesium in the finished product (14).

Papayas are tasty tropical fruits that are especially high in potassium and magnesium. In fact, one 11-ounce (310-gram) papaya delivers about 15% and 19% of the recommended intakes for potassium and magnesium, respectively (15).

One study in 230 women found that those who experienced muscle cramps consumed less dietary potassium than those who did not experience this symptom (16).

Therefore, consuming more potassium-rich foods like papayas may help reduce your risk of muscle cramps. However, more research in this area is needed.

Beet greens are the leafy, nutritious tops of the beet plant. They’re amongst the most nutritious greens you can eat and packed with a number of nutrients that support muscle health and may reduce your risk of muscle cramps.

For example, 1 cup (144 grams) of cooked beet greens contains over 20% of the recommended intake for both potassium and magnesium. They’re also rich in calcium, phosphorus, and B vitamins, which are important for muscle function as well (17).

What’s more, beet greens are loaded with nitrates, which are compounds that help improve blood vessel function, ensuring proper blood flow to your muscles. Optimizing blood flow may help reduce muscle cramps (18).

Fermented foods, such as pickles and kimchi, are typically high in sodium and other nutrients that may help reduce muscle cramps. Interestingly, some research has shown that consuming pickle juice may help inhibit electrically induced muscle cramps in athletes.

A study in male athletes demonstrated that drinking small amounts of pickle juice strained from whole pickles reduced electrically-induced muscle cramp duration by 49.1 seconds, compared with drinking plain water or no fluids at all (19).

Pickles, along with other fermented foods including kimchi and sauerkraut, are rich in electrolytes like sodium and may be a good choice for those who experience frequent muscle cramps.

However, keep in mind that more research is needed before fermented foods and beverages can be recommended as a treatment for muscle cramps.

Salmon is an incredibly rich source of protein, healthy anti-inflammatory fats, and other nutrients that may help prevent muscle cramps, including B vitamins, potassium, magnesium, and phosphorus (20).

Salmon is also high in iron, a mineral that’s essential for healthy blood cell production, the oxygenation of muscle tissue, and blood flow, which are important for muscle cramp prevention (21).

Additionally, salmon is a good source of vitamin D. Having healthy blood levels of vitamin D is vital for muscle function, and being deficient in this nutrient may lead to muscular symptoms, such as muscle pain, spasms, and weakness (22).

Wild-caught salmon is a rich source of vitamin D and has been shown to contain between 8–55 mcg per 3.5 ounces (100 grams).

The current daily intake recommendation for vitamin D is 15 mcg per day for adults, making wild-caught salmon a smart choice for people looking to increase their intake of this important vitamin (23, 24).

Smoothies are an excellent choice for people who experience muscle cramps. They’re not only hydrating but also can be customized to contain a hearty dose of muscle-supporting nutrients.

For example, combining frozen berries, spinach, almond butter, and Greek yogurt in an easy-to-drink smoothie can help deliver the vitamins and minerals that your muscles need to function at an optimal level.

Plus, sipping on nutrient-rich smoothies may prevent muscle cramps by ensuring your body is properly hydrated and fueled.

Sardines may be tiny, but they pack a punch when it comes to nutrition.

These small fish are especially high in nutrients that may help prevent and relieve muscle cramps, including calcium, iron, phosphorus, potassium, sodium, vitamin D, and magnesium (25).

They’re also high in selenium, a mineral that plays an essential role in muscle function. Low selenium levels may lead to muscle weakness or other muscular problems, making it important to include enough selenium-rich foods like sardines in your diet (26).

Muscle cramps are a painful symptom experienced by many people.

Fortunately, eating nutrient-dense foods rich in certain vitamins and minerals may help prevent and treat muscle cramps.

If you frequently experience muscle cramps, try adding a few of the foods and beverages on this list into your diet for natural relief.

If your symptoms don’t improve or worsen, be sure to speak with your healthcare provider about possible causes and treatment options.