On this page
The short answer If your problem is timing (jet lag, a body clock that runs late), melatonin is the better-studied choice, at low doses. If you simply sleep lightly or poorly, magnesium is a gentler, lower-stakes experiment, but its evidence is thin. Neither is a treatment for chronic insomnia, and for most people the honest answer is “start with habits, then maybe one of these.”
Melatonin and magnesium get lumped together on the supplement shelf, but they do different jobs. Melatonin is a timing signal. Magnesium is a mineral you get from food, and its sleep effect, if there is one, is small and indirect. Here’s how they compare on the points that matter.
| Melatonin | Magnesium | |
|---|---|---|
| What it is | A hormone your brain releases in darkness; supplements are usually synthetic | A dietary mineral found in greens, nuts, beans and whole grains |
| Evidence grade for sleep | Moderate evidence for jet lag and late body clocks; modest for insomnia | Limited evidence |
| Best-studied use | Jet lag, delayed sleep-wake phase disorder | Older adults with insomnia symptoms |
| Average effect on falling asleep | About 7 minutes faster than placebo (19 trials) | About 17 minutes faster than placebo (3 small trials, low-quality evidence) |
| AASM position on chronic insomnia | Weak recommendation against | Not evaluated |
| Studied amounts | CDC says 0.5 to 1 mg is often enough to shift the body clock | About 75 to 500 mg elemental magnesium a day |
| Upper limit or caution | CDC advises against high doses above 5 mg for jet lag | 350 mg a day from supplements for adults |
| Common side effects | Headache, dizziness, nausea, next-day sleepiness | Diarrhea, nausea, cramping |
| Timing | Matters a lot; the clock time you take it shifts your rhythm | Not tested; evening is the usual choice |
| Label accuracy | Gummies tested at 74% to 347% of the label | Check the elemental amount, not the compound weight |
Which one should you try?
It depends on what’s actually wrong with your sleep. These are editorial starting points, not prescriptions.
- You’ve crossed time zones or your body clock runs late (you can’t fall asleep until 2 am and struggle to wake up): melatonin has the better case, timed carefully and at a low dose.
- You fall asleep fine but sleep lightly, or you want something mild to try first: magnesium is the lower-risk experiment, especially if your diet is light on greens, nuts and beans.
- You’ve had trouble sleeping three or more nights a week for three months: that’s chronic insomnia, and neither supplement is the answer. Cognitive behavioral therapy for insomnia (CBT-I) is.
- You take prescription medication, have kidney disease, epilepsy or take a blood thinner: talk to a pharmacist before either one.
How melatonin works, and what the trials show
Your brain makes melatonin in response to darkness, and it helps set your circadian rhythm. A supplement doesn’t knock you out the way a sleeping pill does. It nudges your internal clock earlier or later depending on when you take it.
That’s why the evidence splits so sharply by use. For general sleep trouble, a meta-analysis of 19 trials with 1,683 people found melatonin shortened the time to fall asleep by about 7 minutes and added about 8 minutes of total sleep compared with placebo. The authors called the effect modest. The American Academy of Sleep Medicine’s 2017 guideline suggests clinicians not use melatonin for chronic insomnia in adults, a weak recommendation.
For timing problems, the picture is better. NIH’s complementary health center says research suggests melatonin may help with jet lag, and that it appears to help people with delayed sleep-wake phase disorder, where one trial found people fell asleep about 34 minutes earlier on average.
Dose is where people go wrong. The CDC’s travel guidance says 0.5 to 1 mg is often enough to shift the body clock and that high doses above 5 mg aren’t recommended, partly because leftover melatonin can linger at the wrong time of day. Many store products contain far more than that. Our melatonin dosage guide goes through the numbers.
How magnesium works, and what the trials show
Magnesium isn’t a sleep hormone. It’s a mineral involved in nerve and muscle function, and the theory is that low intake may make sleep worse. The research is sparse. NCCIH says there’s very little research on magnesium supplements for insomnia, not enough to say whether they work.
The headline number comes from a 2021 meta-analysis of three small trials in 151 older adults: people taking magnesium fell asleep about 17 minutes faster than those on placebo. That sounds better than melatonin’s 7 minutes, but don’t compare them directly. The magnesium figure rests on three small trials the authors rated as low to very low quality, while melatonin’s comes from 19 trials. A 2025 trial in 155 younger adults found that 250 mg of magnesium bisglycinate lowered insomnia scores slightly more than placebo, an effect the authors called small.
The full breakdown of those trials, including which forms were used, is in magnesium for sleep. If you’re choosing a form, glycinate vs citrate covers why citrate tends to act as a laxative.
Is melatonin or magnesium safer?
Both are generally well tolerated in the short term, with different risks.
With melatonin, short-term studies have reported only mild side effects such as headache, dizziness, nausea and sleepiness. Long-term safety data are lacking. NCCIH says people with epilepsy or who take blood thinners need medical supervision, that it may stay active longer in older adults and cause daytime drowsiness, and that the AASM recommends against it for people with dementia. Products also vary: a 2023 analysis found melatonin gummies contained 74% to 347% of the labeled amount, and only 3 of 25 were within 10% of the label.
Children are a real concern. NCCIH reports an estimated 11,000 emergency department visits from 2019 to 2022 for unsupervised melatonin ingestion by children 5 and under. Store it like medicine, and ask your pediatrician before giving it to a child.
With magnesium, the usual problem is your gut. Too much from supplements can cause diarrhea, nausea and abdominal cramping, and very high intakes can cause an irregular heartbeat. The upper limit for adults is 350 mg a day from supplements and medications; food doesn’t count toward it. People with reduced kidney function are at higher risk, and magnesium can interfere with some antibiotics and osteoporosis drugs.
Can you take melatonin and magnesium together?
There’s no known interaction between them, and one trial tested the combination. In 43 nursing-home residents with insomnia, averaging 78 years old, a nightly supplement of 5 mg melatonin, 225 mg magnesium and 11.25 mg zinc improved sleep quality scores over eight weeks compared with placebo. That’s one small trial in a very specific group, and because the ingredients were given together, it can’t tell you which one did the work.
If you’re thinking about stacking them, the safer move is to try one at a time, so you know what’s helping and what’s just costing money. Check with a pharmacist first if you take other medicines.
Which works faster?
Melatonin is taken for its effect that night, which is why timing matters. The CDC’s jet lag guidance suggests taking it 90 minutes before bed to support your natural evening rise. Magnesium trials ran for three to eight weeks, so if you try it, judge it over a few weeks rather than one night.
Whichever you try, keep a simple log for two to three weeks: bedtime, rough time to fall asleep, wake-ups and how you felt the next day. Without it, it’s hard to tell a real effect from a run of good nights.
When to see a doctor
Talk to your doctor or pharmacist first if you:
- take blood thinners, epilepsy medication, antibiotics, osteoporosis drugs, diuretics or other prescription drugs
- have kidney disease, epilepsy or dementia
- are pregnant or breastfeeding, or want to give either one to a child
- have struggled to sleep at least three nights a week for three months. That’s chronic insomnia, and CBT-I is the treatment the AASM strongly recommends.
- snore loudly, gasp at night or feel very sleepy during the day, which can point to sleep apnea
What to try before either one
Both supplements are small levers. The free ones are bigger: a fixed wake time, caffeine stopped by early afternoon, and getting out of bed when you can’t sleep. Our guide to how to fall asleep fast ranks those by evidence, and sleep supplements: what the evidence shows grades the rest of the shelf. More comparisons live in the supplements hub.
Common questions
Is magnesium or melatonin better for sleep?
Melatonin has more trials and works best for timing problems like jet lag or a late body clock. Magnesium has only a few small trials, mostly in older adults, but it's a mild option for people whose diet is low in it. Neither is recommended as a treatment for chronic insomnia.
Can I take magnesium and melatonin together?
No interaction between them is known, and one small trial in nursing-home residents tested them together with zinc. Trying one at a time tells you which, if either, helps. Ask a pharmacist first if you take other medicines.
Is magnesium safer than melatonin?
Both are generally well tolerated short term. Magnesium's main problem is diarrhea and it needs caution with kidney disease; melatonin can cause next-day sleepiness, needs supervision with epilepsy or blood thinners, and lacks long-term safety data.
How much melatonin is enough?
CDC travel guidance says 0.5 to 1 mg is often enough to shift the body clock and advises against doses above 5 mg for jet lag. Many store products contain more than that.
Written and checked by the Sleep Brief editors. We base every article on published research and guidance from medical bodies, and link the sources inline. How we research.
This article is for general education and isn't medical advice. If poor sleep lasts more than a few weeks, or you snore loudly, stop breathing in your sleep or feel sleepy while driving, talk to a doctor.



