Short answer: Melatonin has more trials behind it: in a meta-analysis of 19 trials, people fell asleep about 7 minutes sooner and slept about 8 minutes longer than on placebo.1 Magnesium's sleep evidence is thinner and inconsistent, rated low to very low certainty.2 NIH says there is not enough strong evidence on melatonin for chronic insomnia.3 No trial has tested one against the other as a sleep treatment.
| Melatonin | Magnesium | |
|---|---|---|
| What it is | A hormone the brain makes in response to darkness; supplements are mostly synthetic3 | A mineral found in food and supplements4 |
| Size of the evidence | 19 placebo-controlled trials, 1,683 people with primary sleep disorders1 | 12 trials in a 2026 review; 3 trials in 151 older adults in a 2021 meta-analysis25 |
| Time to fall asleep vs placebo | About 7 minutes shorter1 | About 17 minutes shorter in older adults, from 3 small trials5 |
| Total sleep vs placebo | About 8 minutes longer1 | 16 minutes longer, not statistically significant5 |
| Quality of evidence | Effects described as modest by the review authors1 | Low to very low certainty; findings inconsistent2 |
| Where it may help most | Jet lag, delayed sleep-wake phase disorder, anxiety before surgery3 | Not established; the 2026 review says it is not supported as a routine insomnia treatment2 |
| Side effects | Mild in short-term studies: headache, dizziness, nausea, sleepiness3 | High supplement doses can cause diarrhea, nausea and abdominal cramping4 |
A 2013 meta-analysis of 19 placebo-controlled trials in 1,683 adults and children with primary sleep disorders found melatonin shortened the time to fall asleep by about 7 minutes and added about 8 minutes of total sleep, with a small improvement in overall sleep quality. Trials that ran longer and used higher amounts showed bigger effects on sleep onset and total sleep. The authors called the effects modest.1
NIH says melatonin may help with jet lag, delayed sleep-wake phase disorder and anxiety before surgery, but there is not enough strong evidence on its effectiveness or safety for chronic insomnia to recommend it.3
A 2021 meta-analysis found 3 trials comparing oral magnesium with placebo in 151 older adults with insomnia. Time to fall asleep was about 17 minutes shorter on magnesium; total sleep was 16 minutes longer, but that was not statistically significant. All three trials had moderate to high risk of bias, and the evidence was rated low to very low quality.5
A 2026 review of 12 trials in adults found the results inconsistent across questionnaires, sleep EEG, activity trackers and body markers. It rated the certainty low to very low and concluded the evidence does not support magnesium as a routine treatment for insomnia, though it may give modest benefits on some self-reported measures.2
Not as a sleep treatment. One 8-week trial in 84 women with polycystic ovary syndrome, aimed mainly at hormones and metabolism, gave magnesium, melatonin, both, or placebo. The abstract reports a significant drop in a sleep quality score in the melatonin and combined groups; it does not report one for magnesium alone.6 That is one small trial in a specific group, so it does not settle which works better for sleep.
This is general information, not personal advice. More detail: the Melatonin and Magnesium Bisglycinate guides, Melatonin vs valerian: which sleep aid has better evidence? and Magnesium citrate vs magnesium glycinate: which form?.