Caffeine and sleep
Caffeine Calculator: How Much Caffeine Is Left at Bedtime
Add your coffees, teas or energy drinks and your bedtime to estimate how much caffeine is still in your body when you lie down, and when it fades.
Caffeine leaves your body slowly: every few hours, about half of what is left gets cleared. That interval, the half-life, ranges from about 2 to 10 hours depending on the person [1]. Using our middle setting of a 5-hour half-life, a coffee at 8:00 AM and another at 2:00 PM still leave around 44 mg in your system at an 11:00 PM bedtime. Add your own drinks and bedtime above to see your numbers.
How caffeine half-life works
Caffeine is absorbed quickly from the stomach and small intestine, and blood levels usually peak within the first 30 minutes or so [1]. Then your liver takes over, breaking most of it down through a single enzyme, CYP1A2 [3]. The clearing follows a steady pattern: in each half-life, half of the remaining caffeine goes. After one half-life a 100 mg coffee leaves 50 mg, after two 25 mg, after three about 12 mg. It never drops off a cliff. It just fades.
That is why the afternoon coffee matters more than the morning one. By bedtime, the morning cup has had many more half-lives to fade.
How the calculator works
This is our own simple model, not a clinical tool. For each drink, the calculator assumes the caffeine is absorbed in a straight line over 30 minutes, then cleared at the half-life you choose. In formula form:
- Caffeine left from one drink = dose × 0.5(hours since the drink - 0.5) ÷ half-life
- Total = the sum over all your drinks
- Latest time for a 100 mg coffee = bedtime - (0.5 h + half-life × log2(100 ÷ your bedtime level))
Two of the inputs are judgment calls we made, and you should know which. The half-life settings of 3, 5, 7 and 10 hours are our picks from the published 2 to 10 hour range [1], with 5 hours as a middle guess, not a measured average. The bedtime levels of 25, 50 and 100 mg are reference points we chose too. The 50 mg default is about half of our 8-ounce coffee preset. No study or health agency names it as a safe amount of caffeine at bedtime.
Alongside the model, the calculator shows a cut-off from a 2023 meta-analysis of 24 studies, which concluded that a coffee of about 107 mg should be drunk at least 8.8 hours before bed to avoid losing sleep time [5]. That rule comes from measured sleep, not from modeled caffeine levels, and at the default settings it is the stricter of the two.
The drink presets are our round numbers, and real drinks vary a lot. The FDA lists 113 to 247 mg for a 12-ounce regular brewed coffee, 71 mg for black tea, 37 mg for green tea, 23 to 83 mg for caffeinated soft drinks and 41 to 246 mg for energy drinks, all per 12 ounces, and 2 to 15 mg for an 8-ounce decaf [6]. If you know the label value, choose "Other" and type it in.
Why your half-life might be 3 hours or 10
Ask two friends to drink the same espresso at 4 PM and one may sleep soundly while the other stares at the ceiling. Much of that gap is in the genes: in twin research on people who neither smoked nor used hormonal birth control, genes accounted for most of the variation in how much caffeine stayed in the blood [3]. Lifestyle does the rest. Smoking speeds caffeine clearance, by as much as 50% [1], so smokers may want the fast setting [3]. Birth control pills do the opposite and slow clearance [3], which points to the slow setting.
Pregnancy slows it a lot: caffeine's half-life is about twice as long in later pregnancy [2]. If you are pregnant, talk to your provider about caffeine rather than relying on a calculator [6]. Liver disease and some medicines can also change how caffeine is processed [3], and a pharmacist can check yours. No idea where you fit? Start with the middle setting. If a lunchtime latte still buzzes at midnight, move to slow.
A worked example: two coffees and an 11 PM bedtime
Two 8-ounce cups of brewed coffee (about 100 mg each in our preset), one at 8:00 AM and one at 2:00 PM, with lights out at 11:00 PM and the 50 mg reference level:
| Half-life setting | From the 8 AM cup | From the 2 PM cup | Total at 11 PM | Falls to 50 mg |
|---|---|---|---|---|
| Fast (3 h) | 4 mg | 14 mg | 18 mg | 6:28 PM |
| Middle (5 h) | 13 mg | 31 mg | 44 mg | 10:07 PM |
| Slow (7 h) | 24 mg | 43 mg | 67 mg | 1:57 AM |
With the middle setting, the latest time for a single 100 mg coffee to fade to 50 mg by 11:00 PM is 5:30 PM. The meta-analysis rule puts it much earlier, at 2:12 PM, so that 2:00 PM cup is right on the edge.
Reading your result
The number at bedtime is a rough guide, not a verdict, and the research says to stay cautious. In one home study, a large 400 mg dose taken 6 hours before bed cut measured sleep by more than an hour, yet people's own sleep diaries picked up less of the loss [4]. Across studies, caffeine shortened sleep by about 45 minutes on average and reduced deep sleep [5]. The Sleep Foundation's advice is to avoid caffeine for at least 8 hours before bed [2].
So when sleep matters to you, go by whichever of the two cut-off times is earlier. For the general rule of thumb without the math, see when to stop drinking coffee before bed. If coffee seems to make you sleepier instead, that is a different puzzle, covered in why coffee can make you sleepy. And if you drink caffeine on purpose right before a short daytime nap, the caffeine nap explains how that works.
Limits and assumptions
The model is deliberately simple. It treats your half-life as constant through the day and absorption as complete after 30 minutes, while food, dose and individual biology shift both. Drink amounts are guesses too: the same size coffee can differ by more than double between brews and shops [6]. And sensitivity differs, since the same amount of caffeine affects people differently [6], so a "low" bedtime level can still keep some sleepers awake.
It is not for medical decisions. If you are pregnant, have liver disease or take regular medicines, ask your doctor or pharmacist about caffeine. And if you have cut back on caffeine and still struggle to sleep most nights for weeks, talk to a doctor: persistent insomnia has many causes besides coffee.
Frequently asked questions
How long does caffeine take to wear off?
Longer than most people think. Caffeine is absorbed fast, with blood levels peaking within about 30 minutes, but its half-life ranges from about 2 to 10 hours between people [1]. In our calculator's model, with its middle 5-hour setting, a 100 mg coffee still leaves about 50 mg in your body five and a half hours later, and about 25 mg after ten and a half hours.
What is the half-life of caffeine?
It is the time your body takes to clear half of the caffeine in it. Estimates range from about 2 hours to as much as 12 [2]. Smoking speeds clearance up, while birth control pills slow it down [3], and caffeine lasts about twice as long in people in the later stages of pregnancy [2]. That spread is why the calculator lets you pick a fast, middle, slow or very slow setting instead of assuming one number fits everyone.
Can caffeine affect my sleep even if I fall asleep fine?
Yes. In a home study, 400 mg of caffeine taken 6 hours before bed cut measured sleep by more than an hour, yet in their own sleep diaries people reported a smaller drop that did not reach statistical significance [4]. Falling asleep easily does not mean caffeine left your night untouched.
How much caffeine is too much in a day?
For most healthy adults, the FDA cites 400 mg a day as an amount not generally linked to negative effects, roughly two to three 12-ounce cups of coffee [6]. People differ widely in sensitivity, and the FDA suggests asking a health care provider if you are pregnant, trying to become pregnant, breastfeeding, or taking medicines or living with conditions that may interact with caffeine.
Sources
- O'Callaghan F, Muurlink O, Reid N, Risk Management and Healthcare Policy. Effects of caffeine on sleep quality and daytime functioning (2018)
- Sleep Foundation. Caffeine and Sleep Problems
- Grzegorzewski J, Bartsch F, Köller A, König M, Frontiers in Pharmacology. Pharmacokinetics of Caffeine: A Systematic Analysis of Reported Data for Application in Metabolic Phenotyping and Liver Function Testing (2022)
- Drake C, Roehrs T, Shambroom J, Roth T, Journal of Clinical Sleep Medicine. Caffeine Effects on Sleep Taken 0, 3, or 6 Hours before Going to Bed (2013)
- Gardiner C et al., Sleep Medicine Reviews. The effect of caffeine on subsequent sleep: A systematic review and meta-analysis (2023)
- U.S. Food and Drug Administration. Spilling the Beans: How Much Caffeine is Too Much?
This page is general information, not medical advice. Sleep needs vary; if you have persistent insomnia, loud snoring, pauses in breathing or daytime sleepiness that affects your safety, see a doctor.