Getting good-quality sleep does more than just help you wake up refreshed—it could also extend your lifespan. A 2023 study found that people who consistently fell asleep easily, stayed asleep through the night, and woke up feeling rested had a significantly lower risk of early death, and were 30% less likely to die from any cause, 21% less likely to have heart disease, 19% lower risk of cancer, and 40% lower risk from other causes. Given these benefits, it’s no wonder many turn to supplements to improve their sleep. Two of the most popular options are melatonin and magnesium. But which one truly helps you drift into deep, peaceful sleep?Role of Melatonin In SleepMelatonin is a hormone naturally produced by the body that helps signal it’s time to sleep,” says Kenneth Lee, M.D., medical director of the Sleep Disorders Center at UChicago Medicine. According to the Mayo Clinic, melatonin levels rise in the evening when it gets dark and drop in the morning with daylight. “It regulates your circadian rhythm, telling your body when to rest,” adds dietitian Stephanie Crabtree, M.S., R.D.Melatonin production stays steady through young adulthood but begins to decline after age 40, according to the Cleveland Clinic. That’s one reason melatonin supplements are often studied for older adults. Dr. Lee notes that it can be especially helpful for issues like jet lag, shift work, or misaligned sleep schedules. “If you’re someone who can’t fall asleep until 1 a.m. but need to wake up early, melatonin taken at the right time can help shift your body clock,” he explains.A 2022 review in Neuroscience & Biobehavioral Reviews found that melatonin helped people with sleep and neurodevelopmental disorders fall asleep faster and stay asleep longer. However, research is mixed for those using it as a general sleep aid. A Sleep Medicine Reviews analysis of 24 studies concluded that melatonin may help some people but is not consistently effective for all.Side Effects of MelatoninAccording to the Mayo Clinic, oral melatonin can sometimes cause headaches, dizziness, or nausea. Less common effects may include mild tremors, anxiety, or confusion. It can also interact with medications such as blood thinners, diabetes drugs, and contraceptives, so it’s important to consult your doctor before use.How Magnesium Supports Better SleepMagnesium is a vital mineral involved in hundreds of body processes, including those linked to rest. “It helps calm the nervous system, relax muscles, and regulate neurotransmitters, which together promote sleep,” says Crabtree. It also supports the body’s natural production of melatonin.Unlike melatonin, magnesium doesn’t directly trigger sleep but may improve relaxation and reduce nighttime restlessness. “It helps regulate GABA, a neurotransmitter that quiets the brain,” says Dr. Lee. A 2024 study in Sleep Medicine: X found that magnesium L-threonate supplementation improved sleep quality, though the results were based on self-reported data. “In my experience, some patients find magnesium helpful, while others notice little change,” Dr. Lee adds.Side Effects of MagnesiumAccording to Dr. Lee, magnesium may cause nausea, diarrhea, or stomach cramps, especially at high doses. The NIH also notes that it can interfere with certain medications, including antibiotics, diuretics, and drugs for osteoporosis or acid reflux.Melatonin vs. magnesium: Which Is Better?Research remains inconclusive on which supplement works best. “Melatonin may help if your main issue is falling asleep, or if you’re adjusting to jet lag or shift changes,” says Crabtree. “But magnesium can be more effective for restless nights or tension that keeps you from relaxing. It also supports deep, restorative sleep and can be used safely for longer periods.”Natural Ways To Sleep BetterBefore turning to supplements, experts suggest improving your sleep habits. Dr. Lee recommends:Practicing good sleep hygiene: Use your bed only for sleep and intimacy, avoid screens or heavy meals before bed, and create a calming pre-sleep routine.Trying cognitive behavioral therapy for insomnia (CBT-I): This structured approach helps retrain your mind and body for better sleep.Getting screened for sleep disorders: Persistent sleep problems may signal conditions like sleep apnea or restless legs syndrome, which require medical care.Dietary supplements are meant to complement your diet, not replace medical treatment. They are not designed to diagnose, treat, or cure illnesses. Always consult a healthcare professional before starting any supplement, especially if you are pregnant, breastfeeding, or considering giving it to a child.