by Strong Mornings See our plans

Melatonin vs magnesium for sleep: which is better for insomnia?

Neither is clearly better. Melatonin is a timing signal, so it fits a shifted body clock (jet lag, night shifts, a very late bedtime). Magnesium is a mineral with a modest, low-quality evidence base for sleep, mostly in older adults, and it fits best when your intake is low. For long-term insomnia, guidelines put CBT-I ahead of both. This is not medical advice: check with a doctor or pharmacist if you take other medicines, are pregnant, or have kidney disease.

Not sure which kind of problem you have? Our free 2-minute sleep quiz shows how long you lie awake and gives you a starting sleep window, so you can judge any supplement against a number. Below: what each one does, a side-by-side table, what the guidelines say, safety points, and a two-week test that tells you whether either is worth keeping.

Melatonin vs magnesium for sleep: the short version

MelatoninMagnesium
What it isA hormone your brain releases in the evening; a supplement copies itAn essential mineral; supplements come as glycinate, citrate, oxide and others
Works onBody-clock timing: when "night" startsMuscle and nerve relaxation; a possible gap if your diet is low
Best fitJet lag, shift work, a delayed sleep phase (sleepy at 3am, groggy at 7am)Tension, leg cramps, low dietary intake; small trials in older adults
Evidence for insomniaSmall average effect on time to fall asleep; the AASM suggests against it for chronic insomniaLow-quality evidence; small trials; no guideline recommends it
Common side effectsDaytime sleepiness, headache, dizziness, vivid dreamsLoose stools, cramps, nausea (more with higher doses)
Main riskLabels that do not match the contents; interactionsToo much with kidney disease; interactions with some medicines
Treats chronic insomnia?NoNo

The popular "melatonin vs magnesium" articles mostly end at "it depends on your problem". That is right as far as it goes, and the rest of this page is about what it depends on.

What melatonin does, and who it is for

Melatonin rises in the evening when light fades and tells your body it is night. It does not knock you out like a sedative. That is why it works best as a timing tool. Taken a few hours before your natural bedtime, it can nudge the clock earlier. Taken at bedtime, it mostly acts as a small cue. Reviews of trials in adults with insomnia find a modest average shortening of the time to fall asleep, a matter of minutes, with wide differences between people. The American Academy of Sleep Medicine (AASM) 2017 guideline on drug treatment of chronic insomnia suggests against melatonin for sleep onset or sleep maintenance insomnia, because the benefit was small and uncertain.

Where it does fit: jet lag after crossing several time zones, a night-shift schedule you are trying to flip, and a genuinely late body clock. If you are wide awake until 3am and sleepy at 10am whatever you do, it may be a timing problem and a clinician may suggest melatonin with morning light. If your trouble is lying awake worrying at 11pm, or waking at 3am, timing is probably not your issue. See why melatonin stops working and how to fall asleep when you are not tired.

What magnesium does, and who it is for

Magnesium takes part in muscle relaxation and nerve signalling. Many adults eat less than the recommended amount, and a low intake may go with poorer sleep, but a link is not proof that a pill fixes it. A systematic review of magnesium for sleep in older adults found low-quality evidence for a small benefit in sleep onset, and small trials with short follow-up. A few small studies report better subjective sleep; none shows that magnesium treats chronic insomnia. No major guideline recommends it.

It may be worth a try if your diet is thin on greens, beans, nuts and whole grains, you get night-time leg cramps, or a clinician has found a low level. Different forms absorb differently; glycinate is often chosen for sleep because it is gentler on the gut than oxide, but that is a preference, not a proven sleep effect. The NIH Office of Dietary Supplements sets an upper limit of 350 mg a day from supplements for adults (food does not count toward it). Higher amounts commonly cause diarrhoea. People with kidney disease should not take magnesium supplements without medical advice.

Which should you try first?

Can you take melatonin and magnesium together?

Many products combine them. Taking both is not known to be dangerous for most healthy adults, but there is no good evidence that the combination works better than either alone, and an expert quoted in a 2025 news piece said the same. The practical problem is that if you start both at once and sleep improves, you cannot tell which did it, or whether it was the better routine you started the same week. Try one at a time.

Safety points that popular articles skip

  1. Labels can be wrong. A 2023 JAMA research letter (Cohen and colleagues) tested 25 melatonin gummy products: 22 had inaccurate labels, and the actual melatonin ranged from 74% to 347% of the amount stated. Supplements are not approved by the FDA before sale. A tested-by-a-third-party seal (USP, for example) is a better sign than a brand name.
  2. Interactions. Melatonin may interact with blood thinners, diabetes medicines and blood pressure medicines. Magnesium can reduce the absorption of some antibiotics and bone medicines. Ask a pharmacist before adding either.
  3. Pregnancy, breastfeeding, children, kidney disease, seizure disorders: talk to a doctor first.
  4. Driving. Melatonin can leave some people sleepy the next morning; do not drive if you feel foggy.
  5. Long-term use. Short-term melatonin use looks safe for most adults; long-term safety is not well studied, according to the National Center for Complementary and Integrative Health.

A two-week test: is either one worth keeping?

  1. Nights 1 to 4: baseline. Fill in a sleep diary: time in bed, minutes to fall asleep, wake-ups, wake time. Keep the same wake time every day.
  2. Nights 5 to 14: one product only. Use the lowest labeled amount you can find, from a brand with third-party testing. For melatonin, ask a clinician when to take it for your goal; for magnesium, take it with the evening meal if it upsets your stomach.
  3. Hold everything else steady. No new caffeine rules, no new alcohol rules, no new bedtime that week; otherwise you cannot tell what worked.
  4. Judge on the diary. If minutes to fall asleep and wake-ups did not change, stop. A bottle that does nothing is not "building up".
  5. Then, if you still lie awake, use the part with the strongest evidence: a fixed wake time and a sleep window matched to your real sleep, as in sleep restriction for insomnia.

What helps more than either bottle

The 2016 American College of Physicians guideline and the AASM's 2021 behavioural guideline both put CBT-I first for chronic insomnia. Its parts are free to use: a fixed wake time, a sleep window that matches the sleep you actually get, leaving the bed when you cannot sleep, and a wind-down that does not involve a bright phone. Supplements, if used at all, sit beside that. For a fuller comparison of what is on the shelf, read best sleep supplements for insomnia and best over the counter sleep aid for insomnia.

When to see a doctor

See a doctor if insomnia has lasted three months or more, you snore loudly or gasp at night, you feel dangerously sleepy while driving, your mood is sinking, you have restless legs or leg jerks, or you are using supplements most nights and still not sleeping. A doctor can check for sleep apnoea, thyroid problems, low iron and medicine side effects.

Frequently asked questions

Is magnesium or melatonin better for sleep?

Neither is better across the board. Melatonin suits timing problems; magnesium suits low intake and tension. Evidence for both in chronic insomnia is weak, and CBT-I has the strongest evidence.

Can I take magnesium and melatonin together?

Many people do, and it is not known to be harmful for most healthy adults, but there is no good evidence the pair works better than one. Test one at a time and check with a pharmacist if you take other medicines.

Which magnesium is best for sleep?

Glycinate is a common choice because it is easier on the stomach; citrate can loosen the bowels; oxide is poorly absorbed. None is proven best for sleep. Stay under 350 mg a day from supplements unless a doctor says otherwise.

How long before bed should I take them?

Melatonin timing depends on your goal, so ask a clinician. Magnesium is usually taken with the evening meal or an hour or two before bed. Neither works like a sleeping pill.

Is it safe to take melatonin every night?

Short-term use looks safe for most adults, but long-term safety is not well studied. If you need it nightly for weeks, that is a reason to talk to a doctor about the cause.

Why do I feel groggy after melatonin?

The amount may be higher than the label says, or taken too late. Gummies are the least predictable. A lower amount taken earlier is the usual adjustment, with a clinician's advice.

Start with the free part

Before you buy another bottle, take the free sleep quiz: it shows how many minutes you lie awake and which part of the night to fix first. More in all sleep guides.

Sources: Sateia MJ et al., AASM clinical practice guideline for the pharmacologic treatment of chronic insomnia in adults, J Clin Sleep Med, 2017; Edinger JD et al., AASM guideline for behavioral and psychological treatments for insomnia, J Clin Sleep Med, 2021; Qaseem A et al., ACP guideline on management of chronic insomnia, Ann Intern Med, 2016; Cohen PA et al., "Quantity of melatonin and CBD in melatonin gummies sold in the US", JAMA, 2023; Mah J, Pitre T, "Oral magnesium supplementation for insomnia in older adults: a systematic review and meta-analysis", BMC Complement Med Ther, 2021; NIH Office of Dietary Supplements, magnesium and melatonin fact sheets; NIH NCCIH, melatonin: what you need to know. Not medical advice.