Magnesium vs melatonin: which one actually fixes your sleep?

sleep supplements
Magnesium vs melatonin: which one actually fixes your sleep?

Walk into any pharmacy in Munich and ask for something to help you sleep, and you’ll be pointed at two shelves. One holds melatonin, the hormone your pineal gland makes in the dark. The other holds magnesium, a mineral involved in several hundred enzymatic reactions and marketed, increasingly, as the calm one. Both are cheap. Both are sold on the same promise. Both, and I say this with genuine affection for the supplement aisle, are being sold for something they don’t do.

Because here’s the thesis, up front: melatonin is a clock signal and magnesium is a nutrient top-up, and neither is a sedative — so the choice isn’t “which works better”, it’s “which of these two entirely different problems have I actually got?” Answer that honestly and one of them picks itself. Answer it dishonestly and you’ll spend two years alternating between bottles wondering why neither did much.

What each one actually does

Melatonin is a message, not a drug. Your pineal gland starts releasing it a couple of hours before your habitual bedtime, in response to darkness, and it rises through the night and falls before you wake. Its job is to tell every clock-bearing cell in your body what time it is. It is a chronobiotic — a timing agent. The soporific feeling that comes with it is a side effect of the message, not the point of it.

This matters enormously for what you should expect. Taking melatonin does not sedate you the way an antihistamine or a benzodiazepine does. It nudges the phase of your internal clock, and if your clock is already where you want it, nudging it does approximately nothing.

Magnesium is a shortfall you might have. It sits in the middle of ATP metabolism, DNA repair, insulin signalling and — the bit relevant here — nervous-system regulation. It acts as a natural antagonist at NMDA receptors (excitatory, arousing) and supports GABA signalling (calming). That’s a plausible mechanism for a nervous system that’s slightly easier to wind down.

But it’s a repletion mechanism. If you’re already replete, there is no shortfall to correct, and topping up a full tank does nothing. The reason anyone bothers is that a lot of people aren’t replete — roughly half of adults fall below the estimated requirement, and as I’ve written about at length, a normal serum magnesium test won’t tell you, because only about 1% of your body’s magnesium is in your blood and your body will strip it from bone to keep that number looking reassuring.

So: one is a timing signal, one is a deficiency correction. Neither is a sleeping pill. Hold onto that, because the head-to-head only makes sense once you have.

The head-to-head, on the axis that matters

The axis that matters is minutes. Specifically, how many minutes off your sleep onset latency — the time between lights-out and actually being asleep — each one buys against placebo. Here’s the honest comparison, which I don’t think I’ve seen laid out side by side anywhere:

Melatonin Magnesium
Best pooled estimate −7.1 min sleep onset latency −17.4 min sleep onset latency
Total sleep time +8.3 min +16.1 min (not significant)
Participants pooled 1,683 151
Trials pooled 19 3
Evidence certainty Moderate — consistent, adequately powered Low to very low — all trials at moderate-to-high risk of bias
Guideline position AASM 2017: suggest against for insomnia No guideline endorsement

The melatonin numbers come from Ferracioli-Oda and colleagues (PLoS ONE, 2013), who pooled 19 randomised placebo-controlled trials in 1,683 adults and children with primary sleep disorders: sleep onset latency down 7.06 minutes, total sleep time up 8.25 minutes, sleep quality improved by a standardised mean difference of 0.22. All statistically significant. All small.

The magnesium numbers come from Mah and Pitre (BMC Complementary Medicine and Therapies, 2021), who could find exactly three randomised trials of oral magnesium against placebo in older adults with insomnia, across three countries, totalling 151 people. Pooled, sleep onset latency was 17.36 minutes shorter than placebo. Total sleep time improved by 16 minutes and didn’t reach significance.

Now look at that table again, because the interesting bit is the inversion. Magnesium’s point estimate is nearly two and a half times melatonin’s, and magnesium’s evidence is the weaker of the two by a wide margin. Effect size and confidence rank in opposite directions.

That is not a coincidence, and it’s the single most useful thing to understand about supplement comparisons generally. Small trials at high risk of bias produce larger, noisier effect estimates — that’s what the funnel plots of the entire nutrition literature look like. Three trials in 151 people, all of them rated moderate-to-high risk of bias by the authors themselves, will happily hand you a 17-minute number that a properly powered trial would shrink towards nothing. Mah and Pitre said as much: the evidence was “low to very low quality” and the literature “substandard for physicians to make well-informed recommendations.”

And a fresh review just made that point sharper. Lopresti and colleagues (Journal of Dietary Supplements, 2026) went wider — 12 randomised trials of magnesium as a standalone intervention for sleep in adults, searched to June 2026 — and found the results inconsistent across subjective scales, EEG, research-grade actigraphy and consumer wearables alike, at low-to-very-low certainty. Their conclusion: current evidence “does not support oral magnesium as a routine treatment for insomnia.” It may help selected subjective outcomes in some people. It is not a reliable intervention.

So on the pure head-to-head, melatonin has the smaller effect and much better claim to having one. Which, awkwardly, still isn’t good enough.

The bit where both of them lose

Here’s the finding that ought to be on the front of both boxes. The American Academy of Sleep Medicine’s clinical practice guideline for pharmacologic treatment of chronic insomnia (Sateia et al., Journal of Clinical Sleep Medicine, 2017) went agent by agent through everything commonly used for insomnia. On melatonin, the recommendation reads:

“We suggest that clinicians not use melatonin as a treatment for sleep onset or sleep maintenance insomnia (versus no treatment) in adults.”

A weak recommendation, in GRADE terms — but a recommendation against, and it sits in the same list as diphenhydramine, valerian and trazodone, all of which got the same verdict. Magnesium didn’t make the guideline at all, which is its own kind of answer.

Fair enough. So if you have plain insomnia — you get into bed at a sensible hour, you’re tired, and you lie there — the evidence says neither of these bottles is the answer, and the thing that actually works is cognitive behavioural therapy for insomnia. That’s the unglamorous, non-purchasable option, and it beats both by a distance that isn’t close.

Which is worth sitting with for a second, given the stakes. Sleep is not a soft variable: the relationship between sleep duration and mortality is a U-curve with a real cost at both ends. If you’re genuinely sleeping badly, that’s a thing to fix properly, not to spend two years bargaining with at €12 a bottle.

Where melatonin genuinely wins, and how badly people take it

Now the flip side, because melatonin has a real indication and it’s not the one on the packaging.

The same body that recommends against melatonin for insomnia positively endorses it elsewhere. The AASM guideline on intrinsic circadian rhythm sleep-wake disorders (Auger et al., Journal of Clinical Sleep Medicine, 2015) endorses strategically timed melatonin for delayed sleep-wake phase disorder, for blind adults with non-24-hour sleep-wake rhythm disorder, and for children and adolescents with irregular sleep-wake rhythm and comorbid neurological disorders. Not contradictory — different indication. Melatonin is bad at sedating you and good at moving your clock.

The word doing the work is strategically. And this is where nearly everyone, including me for about a year, gets it wrong.

Burgess, Revell and Eastman (Journal of Physiology, 2007) built the human phase response curve for 3 mg of melatonin: 27 subjects, two five-day laboratory sessions each, melatonin or placebo at a fixed clock time, with each person’s shift corrected against their own placebo free-run. The resulting curve says three things:

  • The phase-advance peak — melatonin’s biggest “make tomorrow start earlier” effect — lands about five hours before your dim light melatonin onset, which for most people means the afternoon.
  • The phase-delay peak sits about 11 hours after that onset, shortly after your usual wake time.
  • There is a dead zone of minimal phase shift across the first half of habitual sleep.

Maximum fitted shifts: 1.8 hours earlier, 1.3 hours later. The authors’ own summary is the sentence worth pinning up: taking exogenous melatonin as a sleep aid at night “has minimal phase shifting effects.”

Read that against normal behaviour. Your dim light melatonin onset is roughly two hours before you habitually fall asleep, so if you’re asleep by 23:00 it’s around 21:00, and the advance peak is somewhere around late afternoon. The standard move — 3 mg at 22:55, in bed, lights off — is dosing at the very edge of the dead zone. You’re taking a timing signal at the one hour it’s least able to change the timing.

In practice, clinical protocols compromise: a low dose a few hours before your target bedtime, not at it, which trades some of the theoretical shift for something a human being will actually do. That’s the practical rule worth taking from this post: if you’re using melatonin to move your clock earlier, take a small dose in the early evening, several hours before you want to be asleep — not as the last thing before the light goes off. And note the word earlier, because the curve is not symmetrical in a way that lets you ignore direction. To shift later, you want the delay side, which peaks shortly after your usual wake time — a morning dose. Take an evening dose when you needed a delay and you’ll push your clock the wrong way, and be fighting it while you’re trying to be awake.

Two more things about the dose. Physiological doses of around 0.5-1 mg are enough to shift phase, and the 5 and 10 mg tablets on the shelf are far above anything the circadian literature calls for. And you cannot be confident what’s in them: Erland and Saxena (Journal of Clinical Sleep Medicine, 2017) analysed 31 commercial melatonin supplements and found content ranging from 83% below to 478% above the label, with lot-to-lot variation within a single product of up to 465%. More than 71% missed their label claim by more than 10%. Eight of the 31 contained serotonin, which has no business being in there at all.

Where magnesium genuinely wins

Magnesium’s case is not the sleep trials. It’s that the sleep effect, if you get one, is a free side effect of fixing something you probably should fix anyway.

The most-cited trial is Abbasi and colleagues (Journal of Research in Medical Sciences, 2012): 46 older adults with insomnia, 500 mg of magnesium or placebo daily for eight weeks. The magnesium group improved on insomnia severity index, sleep efficiency and sleep onset latency, with serum melatonin up and cortisol down. Encouraging.

And worth reading properly. The abstract simultaneously reports a significant increase in “sleep time” and no significant between-group difference in “total sleep time” (P = 0.37) — which tells you something about the reporting standard. Serum magnesium barely moved between groups (P = 0.06), which is odd in a magnesium supplementation trial, though given how poorly serum tracks magnesium status it isn’t quite the contradiction it looks like. The dose, 500 mg daily, is above the 350 mg tolerable upper limit for supplemental magnesium. Treat it as a hypothesis-generating study in 46 people, not as a protocol.

What makes magnesium worth taking regardless is that the rest of its evidence base isn’t about sleep. Higher dietary magnesium tracks with lower stroke, heart-failure, diabetes and all-cause mortality risk in large cohorts, and the randomised blood-pressure data is modest but real. If you’re one of the half of adults running short, you have a reason to top up that has nothing to do with your sleep onset latency — and if your sleep improves a bit, that’s a bonus you weren’t paying for.

So who should pick which

A framework, since the answer genuinely depends on the problem:

Pick melatonin if your problem is timing, not sleep itself. You can sleep perfectly well — just three hours later than you’d like. You’ve crossed time zones. You’re doing shift work, or coming off a run of very late nights. You’re a teenager or the parent of one, since delayed phase is close to the default setting in adolescence. Dose is 0.5-1 mg, and expect to move your clock by well under two hours either way.

Then work out which direction you’re going, because this is the bit that gets skipped and it’s the bit that decides whether the pill helps or hurts:

You need to sleep… Direction When to take it
Earlier — delayed sleep phase, the teenager problem, eastward travel, un-doing a run of late nights Phase advance Early evening, a few hours before target bedtime
Later — westward travel, rotating onto a night shift, anything that needs you up past your usual limit Phase delay Morning, around your usual wake time

Get that backwards and you don’t just waste the dose — an evening dose when you needed a delay drags your clock further from where you’re trying to put it, and leaves you sleepy in the hours you were trying to stay awake for. “Melatonin is for sleep, so take it at night” is the intuition that produces exactly this mistake.

Pick magnesium if your diet is genuinely thin on leafy greens, nuts, legumes and whole grains, or you’re supplementing vitamin D long-term and want it to work. Glycinate or citrate, 200-300 mg elemental, evening if you like the mildly calming feel. Judge it on the deficiency case, not the sleep case, and treat any sleep improvement as a rounding error in your favour.

Pick neither if your problem is classic insomnia — right bedtime, genuinely tired, mind won’t stop. Both guidelines say what they say. CBT-I is the intervention with the effect size, and it’s free of both the 478%-over-label problem and the loose-stools problem.

And before either, fix the free variables. Regular sleep and wake times — sleep regularity predicts mortality better than sleep duration does, which is one of the more genuinely surprising findings in this literature. Morning daylight, which moves your clock harder than any pill. Evening alcohol, which is a sedative and a sleep-architecture wrecker in the same glass. Those three beat both supplements combined, and I say that as someone with a bottle of glycinate on the shelf.

The verdict

Melatonin wins the evidence contest and loses the usefulness contest for most people who buy it, because the thing it’s good at — moving your body clock — is not the thing most people want from it. Magnesium loses the evidence contest, has the larger and much shakier point estimate, and is still the more defensible purchase for a lot of people, because its case rests on correcting a common dietary shortfall rather than on three small trials of 151 pensioners.

If I had to compress it to one line: melatonin is for when your clock is wrong; magnesium is for when your diet is; and if neither of those is your problem, the bottle isn’t either.

Which is a slightly deflating place to end a comparison post. But it’s better than the alternative, where you buy both, take them together, feel nothing in particular, and conclude that your sleep is simply beyond help. It probably isn’t. It just isn’t a supplement problem.

Related posts

What's your biological age?

Reading about longevity is step one. Knowing your number is step two — a free 2-minute test, no signup.

Check your biological age →