Workout recovery and sleep go hand-in-hand. You can have a dedicated stretching and foam rolling routine, and regularly hit up the sauna, but if you aren’t getting adequate sleep, your muscles are going to take a hit.

A 2021 scientific study published in Physiological Reports found that a single night of not getting enough sleep can get in the way of muscle repair and growth. That’s how important sleep is, especially if you’re trying to transform your body. But instead of reaching for the melatonin, taking a magnesium supplement can be more effective because the micronutrient plays a critical role in both muscle function and sleep.

But which is best to help you recover from a workout and, ideally, get a good night’s sleep? We talked to a doctor, pharmacist, and dietitian who have all studied the mineral to get advice on which products work best.

What exactly does magnesium do?

If you’re going to spend money on a nutritional supplement, it helps to have a basic understanding of how it works. Brace yourself: This micronutrient does a lot.

Here’s a rundown of magnesium’s job description, according to Stella Volpe, PhD, RDN, a registered dietitian and professor at Virginia Tech: it helps make protein, supports bone health by activating vitamin D (crucial for calcium absorption), and regulates blood sugar concentrations.

That’s not even getting into how it supports muscle recovery and sleep. Sports medicine doctor and Sunrider International chief medical advisor Reuben Chen, MD, explains that magnesium supports workout recovery by relaxing the muscles, reducing post-exercise cramping, and restoring energy at the cellular level.

“Magnesium also helps ease soreness, while keeping the nervous system calm and balanced, allowing your body to recover faster,” he says. Volpe adds to this, saying that magnesium helps reduce inflammation—another way it supports workout recovery.

As for sleep, Chen explains that magnesium calms the nervous system, priming the body for rest. “It also helps regulate melatonin, the hormone that guides our sleep-wake cycles, making it easier to fall asleep and stay asleep,” he adds.

It’s important to note: all the experts we talked to said that most people get all the magnesium they need through their daily diet. “Generally speaking, people are not deficient in magnesium if they are eating a balanced diet,” says Alexandre Chan, PharmD, MPH, a professor of clinical pharmacy at UC Irvine. Especially if you eat a primarily plant-based diet, you’re likely getting enough. Some top food sources of magnesium include almonds, spinach, cashews, black beans, rice, potatoes, oatmeal, and salmon.

So is there a benefit to taking a magnesium supplement? Maybe. “We lose magnesium via sweat and stress,” registered dietitian Brittany Michels, RDN, LDN, CPT, previously told GQ. That means, if your shirt is soaked after a workout, your body could likely benefit from some replenishing.

Just make sure not to go overboard. In the case of magnesium, more is not better. According to the National Institutes of Health, adult men should aim to get between 400 and 320 milligrams of magnesium a day, and more than 5,000 milligrams a day is considered toxic. Signs you’re getting too much magnesium include nausea, diarrhoea, muscle weakness, difficulty breathing, and heart palpitations.

What type of magnesium products are best for recovery and sleep?

When shopping for magnesium products, consider the types: magnesium glycinate, magnesium citrate, or magnesium malate. Volpe recommends magnesium glycinate because it’s the type of magnesium that’s best absorbed.

Why are there different types of magnesium in the first place and what’s the difference? Volpe explains that when magnesium is chemically bonded with something else (such as an amino acid or citric acid), it’s better absorbed in the body. Magnesium glycinate is a magnesium salt made from magnesium and the amino acid glycinate, which is a neurotransmitter with anti-inflammatory properties. Magnesium citrate is also a magnesium salt, but it’s made of magnesium and citrate, which is an acid found in citrus fruits that supports energy metabolism. Magnesium malate binds magnesium with malic acid. Like citrate, malic acid is also found in fruits (although not typically citrus fruits) and supports energy metabolism.