What you eat, and when you eat it, directly affects how well you sleep. Certain foods contain nutrients that help your brain produce sleep-promoting chemicals like melatonin and serotonin. Others, like caffeine and heavy meals, keep you awake. A study of 432 women found that each 1-point increase in Mediterranean diet adherence was linked to 1.2 percent higher sleep efficiency (Mamalaki et al. 2020).
Track how your diet changes affect rest with the sleep quality calculator. For a complete wind-down checklist, try the sleep hygiene 101 guide.
How Food Affects Your Sleep
Sleep is regulated by hormones and neurotransmitters that your body builds from nutrients in food. The three most important pathways are (Sejbuk et al. 2022):
- Tryptophan to serotonin to melatonin. Tryptophan is an amino acid found in protein-rich foods. Your brain converts it into serotonin (a calming neurotransmitter) and then into melatonin (the hormone that signals it is time to sleep).
- Magnesium. This mineral helps activate the parasympathetic nervous system, the “rest and digest” mode. Low magnesium is linked to poor sleep quality and insomnia (Abbasi et al. 2012).
- Complex carbohydrates. Carbs help tryptophan cross the blood-brain barrier by triggering insulin, which clears competing amino acids from the bloodstream. This is why a small carb-rich snack before bed can help some people sleep (Cleveland Clinic).
Best Foods For Better Sleep
These foods contain the nutrients your brain needs to produce sleep-promoting chemicals:
| Food | Key nutrient | Evidence |
|---|---|---|
| Tart cherry juice | Natural melatonin | Reduced waking time by 17 minutes in older adults with insomnia (Pigeon et al. 2010) |
| Fatty fish (salmon, mackerel) | Omega-3 and vitamin D | Higher omega-3 linked to better sleep quality (Sejbuk et al. 2022) |
| Nuts (almonds, walnuts) | Magnesium, melatonin | Natural source of both magnesium and melatonin (Cleveland Clinic) |
| Turkey and chicken | Tryptophan | High tryptophan content supports melatonin production (Cleveland Clinic) |
| Kiwi | Serotonin, antioxidants | Studies link nightly kiwi to faster sleep onset (Sejbuk et al. 2022) |
| Warm milk | Tryptophan, calcium | Calcium helps the brain use tryptophan to make melatonin (Cleveland Clinic) |
| Whole grains (oats, rice) | Complex carbs | Help tryptophan cross blood-brain barrier (Sejbuk et al. 2022) |
You do not need to eat all of these. Even adding one or two to your evening routine can make a difference. A handful of almonds or a glass of tart cherry juice an hour before bed is a simple starting point.
The overall pattern of your diet matters more than any single food. The Mediterranean diet, which emphasizes fish, vegetables, whole grains, nuts, and olive oil, was linked to better sleep efficiency across all age groups in a 2020 study (Mamalaki et al. 2020). Focus on building a consistently healthy plate rather than searching for one magic food.
Foods And Drinks That Hurt Sleep
Some foods actively work against sleep. Limiting or avoiding these in the hours before bed helps protect your rest:
- Caffeine. Coffee, tea, soda, energy drinks, and dark chocolate all contain caffeine. It blocks adenosine, the brain chemical that builds sleep pressure. Caffeine has a half-life of 5 to 6 hours, meaning half the caffeine from a 3:00 p.m. coffee is still active at 9:00 p.m. The 10-3-2-1-0 sleep rule recommends stopping caffeine 10 hours before bed.
- Alcohol. A drink may help you fall asleep faster, but it fragments sleep in the second half of the night by disrupting REM cycles. Even moderate drinking reduces sleep quality (Sejbuk et al. 2022).
- Spicy foods. Capsaicin raises core body temperature and can trigger acid reflux, both of which delay sleep onset. Avoid spicy meals within 3 hours of bedtime.
- High-fat meals. A study found that meals high in saturated fat led to lighter, less restorative sleep compared to fiber-rich meals (Cleveland Clinic).
- Sugar and refined carbs. A spike in blood sugar followed by a crash can cause middle-of-the-night waking. Complex carbs are better than simple sugars.
When To Eat Your Last Meal
Eating too close to bedtime forces your digestive system to work when it should be winding down. This can raise core body temperature and trigger acid reflux, both of which interfere with falling asleep. Your body needs time to digest before it can shift into sleep mode.
A good rule of thumb is to finish your last large meal at least 2 to 3 hours before bed. If you need a snack closer to bedtime, keep it small (under 200 calories) and choose something with tryptophan or magnesium: a small bowl of oatmeal, a handful of almonds, or a banana with a tablespoon of nut butter (Johns Hopkins).
The sleep consistency calculator can help you track whether meal timing changes improve your sleep pattern over time.
Supplements For Sleep
Some people turn to supplements when diet alone is not enough. Here is what the research shows:
- Melatonin. The most studied sleep supplement. It can help with jet lag and delayed sleep timing but is less effective for general insomnia. A 2023 analysis found that 22 out of 25 melatonin gummies were mislabeled, containing between 74 and 347 percent of the stated dose (NCCIH). Choose third-party tested brands.
- Magnesium. A 2025 randomized controlled trial found that magnesium bisglycinate produced a small but significant improvement in insomnia severity compared to placebo (Burcham et al. 2025). Low magnesium is linked to poor sleep quality (Abbasi et al. 2012).
- Valerian root. A meta-analysis of 18 trials found that valerian reduced the time it takes to fall asleep and improved overall sleep quality compared to placebo (Obeid et al. 2024). Effects are modest and may take 2 to 4 weeks to appear.
Supplements are not a replacement for good sleep habits. They work best when added on top of a healthy diet and a consistent bedtime routine. Talk to your doctor before starting any supplement, especially if you take other medications or have a chronic condition. The stages of sleep guide explains how these nutrients influence each phase of the sleep cycle.
The Gut-Sleep Connection
Your gut and your brain communicate constantly through a pathway called the gut-brain axis. The bacteria in your gut produce neurotransmitters, including serotonin, which is a precursor to melatonin. About 95 percent of the body’s serotonin is made in the gut, not the brain (Li et al. 2025).
A 2025 study found that a diet rich in fiber, fermented foods, and diverse plant foods was positively associated with longer sleep duration in US adults (Li et al. 2025). For a deeper look at this relationship, see our gut-brain connection guide.
Supporting your gut with a varied, fiber-rich diet may improve sleep indirectly by boosting serotonin production. Yogurt, kimchi, sauerkraut, and other fermented foods feed beneficial gut bacteria. The sleep score calculator can track whether dietary changes move the needle on your overall rest.
FAQs
How Soon Before Bed Should I Stop Eating?
Finish your last large meal 2 to 3 hours before bedtime. A small snack under 200 calories is fine closer to bed if it contains tryptophan or magnesium, like almonds or a banana (Johns Hopkins).
Does Warm Milk Actually Help You Sleep?
Warm milk contains both tryptophan and calcium, which help the brain produce melatonin. The effect is mild, but the ritual of drinking something warm can also signal your body that bedtime is near (Cleveland Clinic).
Is Melatonin Safe To Take Every Night?
Short-term use appears safe for most adults. However, melatonin supplements are not closely regulated, and dosage accuracy varies widely. The NCCIH found that most melatonin gummies contain far more or less than the label says (NCCIH). Talk to your doctor about long-term use.
Can Eating Too Little Affect Sleep?
Yes. Going to bed hungry can raise cortisol levels and make it harder to fall asleep. Very low-calorie diets are also linked to lower magnesium and B-vitamin levels, both of which support sleep. If you are dieting, a small protein and carb snack before bed can help (Sejbuk et al. 2022).
Does Alcohol Help You Sleep?
Alcohol makes you feel drowsy and may help you fall asleep faster, but it disrupts sleep architecture in the second half of the night. It suppresses REM sleep, causes more awakenings, and worsens snoring and sleep apnea. Even one or two drinks can reduce sleep quality (Sejbuk et al. 2022).
Are Bananas Good For Sleep?
Yes. Bananas contain magnesium, potassium, and tryptophan. Magnesium helps relax muscles, and tryptophan supports melatonin production. A banana with a tablespoon of almond butter makes a good pre-bed snack (Cleveland Clinic).