Foods for Better Sleep: Tryptophan, Melatonin, Magnesium, and Caffeine
Adults who sleep less than 7 hours per night consume significantly more added sugar, saturated fat, and caffeine than those who get 7 to 9 hours, according to a 2019 analysis of NHANES data covering more than 13,000 American adults published in the Journal of Nutrition. The relationship runs in both directions. What you eat changes how you sleep, and how you sleep changes what you eat. This guide covers the foods and nutrients with the strongest evidence for improving sleep, the ones that disrupt it, and the practical patterns that actually move the needle.
How diet shapes sleep architecture
Sleep is divided into non-REM stages (N1, N2, N3) and REM sleep, cycling roughly every 90 minutes through the night. N3, often called deep or slow-wave sleep, is when growth hormone peaks and the glymphatic system clears metabolic waste from the brain. REM sleep consolidates memory and regulates emotion. Both are essential, and both are sensitive to what and when you eat.
A 2016 review by St-Onge and colleagues in Advances in Nutrition concluded that calorie intake, meal timing, and macronutrient composition all measurably affect sleep architecture. High-carbohydrate meals eaten 4 hours before bed shortened sleep onset latency in several controlled studies, while very high-fat meals tended to reduce slow-wave sleep. The mechanism involves insulin-mediated tryptophan uptake into the brain, where tryptophan is converted first to serotonin and then to melatonin.
The American Academy of Sleep Medicine and the National Sleep Foundation both recommend 7 to 9 hours per night for adults. Roughly 1 in 3 American adults falls short, and chronic short sleep is linked to higher rates of obesity, type 2 diabetes, and cardiovascular disease. Our Sleep Cycle Calculator can help you work backward from your wake time to a bedtime aligned with 5 or 6 complete 90-minute cycles.
Tryptophan: the precursor that needs help
Tryptophan is an essential amino acid the body converts into serotonin and then melatonin. The USDA FoodData Central database lists the richest food sources per 3 ounce cooked portion:
- Turkey breast: 250 to 320 mg
- Chicken breast: 250 to 290 mg
- Salmon: 200 to 250 mg
- Pumpkin seeds, 1 oz: 150 to 200 mg
- Cottage cheese, 1 cup: 300 to 350 mg
- Milk, 1 cup: 100 to 120 mg
- Eggs, 2 large: 180 to 220 mg
- Oats, 1 cup cooked: 50 to 70 mg
The "turkey makes you sleepy" myth is overblown. Turkey has only marginally more tryptophan per ounce than chicken or beef, and a typical Thanksgiving portion delivers about the same tryptophan as an ordinary chicken dinner. Post-meal drowsiness on Thanksgiving is driven mainly by total calorie load, alcohol, and the carbohydrate-heavy side dishes.
What does matter is pairing tryptophan with carbohydrate. After a carb-rich meal, insulin rises and drives competing large neutral amino acids (LNAAs) into muscle, leaving more tryptophan available to cross the blood-brain barrier. This is why a small bowl of oatmeal with milk or a turkey sandwich on whole-grain bread works better than turkey alone. Supplement trials using 1 g of pure tryptophan show modest sleep-onset benefit, but the FDA flagged contamination issues with tryptophan supplements in the 1980s and again in 2011, so food is the safer source.
Dietary melatonin: real but small
Melatonin is the hormone that signals darkness to the body. The pineal gland produces it from serotonin, with secretion rising about 2 hours before habitual bedtime. Melatonin is also present in small amounts in certain foods. A 2017 review in Nutrients by Meng and colleagues compiled the highest dietary concentrations:
- Tart (Montmorency) cherries: roughly 13.5 ng per gram
- Walnuts: about 3.5 ng per gram
- Pistachios: 2.5 ng per gram, varying by cultivar
- Cow milk collected at night: 6 to 25 ng per mL
- Tomatoes: 0.5 to 2 ng per gram
- Grapes and wine: 0.5 to 1.5 ng per gram
The amounts are pharmacologically tiny. One cup of tart cherry juice supplies about 30 micrograms of melatonin, while a typical supplement provides 0.5 to 5 mg (500 to 5,000 micrograms). Even so, randomized trials of tart cherry juice have shown modest improvements in sleep duration and quality, likely because cherries also contain procyanidins that inhibit the enzyme which degrades tryptophan. The protocol used in a 2012 trial by Howatson and colleagues in the European Journal of Nutrition was two 8 oz servings per day, one in the morning and one 30 to 60 minutes before bed, continued for 1 to 2 weeks, producing about 40 extra minutes of total sleep time in older adults with insomnia.
Magnesium and the GABA system
Magnesium is a cofactor for more than 300 enzymatic reactions, including the synthesis of the inhibitory neurotransmitter GABA. Low magnesium intake is associated with subjective sleep complaints and shorter sleep duration in NHANES analyses. The NIH Office of Dietary Supplements sets the adult Adequate Intake at 310 to 320 mg per day for women and 400 to 420 mg for men, and roughly half of US adults fall short.
The richest food sources per serving:
- Pumpkin seeds, 1 oz: 156 mg
- Spinach, 1 cup cooked: 157 mg
- Black beans, 1 cup cooked: 120 mg
- Edamame, 1 cup: 99 mg
- Almonds, 1 oz: 80 mg
- Cashews, 1 oz: 74 mg
- Dark chocolate (70 percent or higher), 1 oz: 64 mg
- Avocado, 1 medium: 58 mg
A 2012 trial by Abbasi and colleagues in the Journal of Research in Medical Sciences randomized 46 older adults with primary insomnia to 320 mg of magnesium oxide per day or placebo for 8 weeks. The magnesium group had modest improvements in subjective sleep quality, sleep onset latency, and circulating renin levels (a marker of deep sleep). A 2018 meta-analysis by Cao and colleagues in Nutrients pooled these and similar trials and concluded the effect is real but small, and most pronounced in older adults with low baseline intake. Effects in younger, magnesium-replete adults are smaller. Use our Magnesium Calculator to estimate intake from food before considering a supplement. Magnesium glycinate and citrate are better absorbed than oxide, which is also more likely to cause loose stools at higher doses.
Caffeine: the most underappreciated sleep disruptor
Caffeine has an average half-life of 5 hours in healthy adults, with a range of 2 to 12 hours driven by CYP1A2 genetics, pregnancy, oral contraceptive use, and smoking. A 2 pm cup of coffee with 200 mg caffeine still has roughly 100 mg in your system at 7 pm and 50 mg at midnight, enough to measurably reduce deep sleep in sensitive individuals.
A 2013 study by Drake and colleagues in the Journal of Clinical Sleep Medicine found that 400 mg of caffeine taken 6 hours before bedtime reduced total sleep time by more than 1 hour. Even caffeine consumed in the morning can affect sleep in slow metabolizers. Practical guidance:
- Stop caffeine 8 to 10 hours before bedtime if you have any sleep complaints.
- Switch to half-caf or decaf after 12 pm.
- Watch for hidden caffeine in chocolate (5 to 35 mg per ounce), energy bars, kombucha (often 10 to 50 mg per bottle), decaf coffee (2 to 15 mg per cup), pain relievers (Excedrin: 65 mg per tablet), and pre-workout supplements (often 150 to 300 mg per scoop).
- Use the Caffeine Half-Life Calculator to estimate residual caffeine at bedtime based on your dose and timing.
Alcohol: the REM thief
Alcohol is a central nervous system depressant that shortens sleep onset latency. This is why a nightcap feels helpful. But the effect reverses in the second half of the night as alcohol is metabolized. Sleep fragments, REM is suppressed, and you wake tired. A 2013 review by Ebrahim and colleagues in Alcoholism: Clinical and Experimental Research concluded that alcohol within 3 hours of bedtime suppresses REM by 20 to 40 percent in the first half of the night and increases wakefulness in the second half.
The American Heart Association recommends that adults who drink limit to 2 drinks per day for men and 1 for women. For sleep specifically, no amount appears beneficial. If sleep quality is a goal, keep alcohol 3 hours or more from bedtime and rehydrate. See our full Alcohol and Health Guide for the broader evidence.
Meal timing and the peripheral clock
The body's master clock in the suprachiasmatic nucleus responds primarily to light. But peripheral clocks in the liver, gut, and pancreas respond to food. Eating late shifts those peripheral clocks, contributing to glucose dysregulation and poorer sleep. A 2021 trial in the British Journal of Nutrition found that eating a large meal within 1 hour of bedtime increased sleep onset latency by about 12 minutes and reduced sleep efficiency by 4 percent.
Practical guidance: stop eating 3 hours before bed, and if you need a snack, keep it under 200 calories with emphasis on protein and complex carbohydrate. Our Meal Timing and Circadian Nutrition Guide covers this in more depth.
A practical sleep-promoting dinner
The goal is a combination of tryptophan, complex carbohydrate, and magnesium. Five templates:
- Salmon (4 oz) with quinoa (1 cup) and roasted broccoli with sliced almonds
- Turkey and black bean bowl with brown rice, avocado, and salsa
- Cottage cheese (1 cup) with pumpkin seeds, berries, and a drizzle of honey
- Tofu stir-fry with edamame, spinach, and soba noodles
- Oatmeal (1 cup cooked) with milk, walnuts, and tart cherries, eaten 2 hours before bed
The protein supplies tryptophan, the carbohydrate improves tryptophan uptake, and the magnesium-rich sides support GABA activity. Add a small cup of tart cherry juice in the evening if you want to layer in dietary melatonin.
What doesn't work as advertised
- Warm milk contains tryptophan, but only about 100 mg per cup, well below the 1 g dose used in supplement trials. The sleep benefit is mostly the soothing routine.
- Lettuce water, a viral TikTok trend, has no clinical evidence. Lactucarium, a mild sedative compound in lettuce, is present in trivial amounts.
- Bananas contain magnesium and tryptophan but in modest quantities (32 mg magnesium per medium banana). Useful but not a magic bullet.
- Kiwifruit has two small but rigorous trials showing modest sleep benefit from 2 kiwifruits 1 hour before bed for 4 weeks. The mechanism may be the high serotonin content. Worth trying, but the evidence base is only a handful of trials.
- Valerian and chamomile have some trial support but the effects are small and the products vary widely. They are reasonable to try as tea but should not be relied on as primary therapy for insomnia.
Strategies that compound
Sleep nutrition works best when combined with sleep hygiene. The highest-yield combinations are:
- Magnesium-rich dinner plus an 8 to 10 hour caffeine cutoff
- 3 hour pre-bed meal cutoff plus tart cherry juice in the evening
- Consistent meal times across the week, which stabilize peripheral clocks
- Morning sunlight exposure within 30 minutes of waking, which anchors the master clock and triggers earlier evening melatonin release
- A cool, dark bedroom and a 30 to 60 minute wind-down without screens
Sleep loss also changes eating behavior. After a night of less than 6 hours of sleep, circulating ghrelin rises and leptin falls, increasing hunger by roughly 300 to 400 calories per day and shifting food preference toward palatable, high-carbohydrate foods, according to a 2004 study by Spiegel and colleagues in the Annals of Internal Medicine. The sleep and diet loops reinforce each other. Use our Sleep Debt Calculator to estimate accumulated sleep loss over the past week, and the Chronotype Quiz to align your eating window with your biological clock.
The bottom line
Food influences sleep through tryptophan availability, dietary melatonin, magnesium status, caffeine burden, alcohol timing, and meal timing. The pattern matters more than any single food: consistent meal times, caffeine cutoff 8 to 10 hours before bed, no alcohol within 3 hours of sleep, and a dinner that combines protein, complex carbohydrate, and magnesium-rich plants. Estimate your caffeine clearance with the Caffeine Half-Life Calculator, your magnesium intake with the Magnesium Calculator, and accumulated sleep loss with the Sleep Debt Calculator. Food is one lever among many, but it is the one you control every day.
Discussion
Share your perspective - be constructive and kind. Comments are visible immediately and moderated by our team.