How the estimate works
Your body clears caffeine at a roughly steady rate. The time it takes to clear half of what is there is the half-life. For healthy adults it sits somewhere around 2 to 8 hours[1], which is why the same afternoon coffee keeps one person awake and leaves another untouched. Genes explain part of the spread, and so do smoking, pregnancy, oral contraceptives, liver health and some medicines[2].
The calculator halves each drink once per half-life and adds the drinks together. It ignores the time caffeine takes to be absorbed, and the milligram values are typical figures. Real drinks vary widely by brand and brew[3]. Treat the result as an estimate with a wide margin, which is why it shows a range.
Where the cut-off times come from
There is no agreed “safe” amount of caffeine at bedtime, so the calculator does not invent one. The cut-off times come from a meta-analysis of 24 studies. Across those studies caffeine shortened sleep by about 45 minutes on average and cut deep sleep. To avoid losing sleep time, the authors’ model put a cup of coffee (about 107 mg) at least 8.8 hours before bed and a pre-workout dose (about 217 mg) at least 13.2 hours before bed. A cup of black tea had no cut-off[4].
Later trials show how much the dose matters. In 23 young men, 100 mg taken as late as 4 hours before bed did not measurably change sleep, while 400 mg disturbed it even when taken 12 hours before[5]. In an older small study, 400 mg taken 6 hours before bed still cost more than an hour of sleep[6]. The honest summary: one ordinary coffee after lunch is a grey zone, and large doses late in the day are not.
What the number cannot tell you
People are poor judges of what caffeine does to their own sleep. In the dose-timing trial, measured sleep got worse in conditions where the participants themselves reported no difference[5]. So “coffee never affects me” is worth testing: move your last caffeine earlier for two weeks and compare how you sleep and feel.
Total intake matters too. Food-safety agencies describe up to about 400 mg a day as generally safe for healthy adults[1][3], and the European agency advises no more than 200 mg a day in pregnancy[1].
Questions people ask
How long does caffeine stay in your system?
With an average half-life of about 5 hours, a quarter of a dose is still present after 10 hours. With a slower half-life of 8 hours, a quarter is still there after 16 hours[1].
When should I stop drinking coffee before bed?
A cautious starting point from the research is about 9 hours before bed for a regular coffee, and about 13 hours for large doses of 200 mg or more[4]. Adjust from there based on your own sleep.
Does tea in the evening matter?
Small doses matter less. The meta-analysis model found no cut-off time for a single cup of black tea[4]. Several cups add up, though, so log them all.
References
- EFSA Panel on Dietetic Products, Nutrition and Allergies. (2015). Scientific opinion on the safety of caffeine. EFSA Journal, 13(5), 4102. DOI
- Nehlig, A. (2018). Interindividual differences in caffeine metabolism and factors driving caffeine consumption. Pharmacological Reviews, 70(2), 384–411. Review. DOI
- U.S. Food and Drug Administration. Spilling the beans: How much caffeine is too much? FDA
- Gardiner, C., Weakley, J., Burke, L. M., et al. (2023). The effect of caffeine on subsequent sleep: A systematic review and meta-analysis. Sleep Medicine Reviews, 69, 101764. 24 studies. DOI
- Gardiner, C. L., Weakley, J., Burke, L. M., et al. (2025). Dose and timing effects of caffeine on subsequent sleep: A randomized clinical crossover trial. Sleep, 48(4), zsae230. 23 young men. DOI
- Drake, C., Roehrs, T., Shambroom, J., & Roth, T. (2013). Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed. Journal of Clinical Sleep Medicine, 9(11), 1195–1200. Small study (n = 12), high dose. DOI
- Edinger, J. D., et al. (2021). Behavioral and psychological treatments for chronic insomnia disorder in adults: An American Academy of Sleep Medicine clinical practice guideline. Journal of Clinical Sleep Medicine, 17(2), 255–262. DOI
Take the Mismatch Quiz
Which mismatch is draining you? The free quiz takes about 4 minutes and points to one pattern worth investigating, such as Caffeine and alcohol timing. It is an educational self-reflection tool, not a diagnosis.
Take the quiz