Caffeine Half-Life & Bedtime Cutoff Calculator
Estimates how much caffeine is still in your body at bedtime with a first-order elimination model: the dose, from a sourced drink preset or a custom amount times servings, halves every half-life, 5 hours by default. It reports the milligrams left at bedtime, the clock time the amount falls below your threshold, 25 mg by default, and the latest time to have the drink, which is bedtime minus half-life × log2(dose ÷ threshold).
Pick a drink, say when you had it and when you plan to sleep, and the calculator estimates how much of that caffeine is still in your body at bedtime. It also gives the time the amount falls below a threshold you choose, how long that takes, and the latest time you could have the same drink and still be under the threshold at bedtime. Times marked "next day" fall after midnight, "day before" marks a cutoff on the previous day, and an unmarked time falls on the day of the drink.
How the calculation works
The model assumes a single dose, absorbed at once and cleared by first-order elimination, which removes a fixed fraction of what is left each hour rather than a fixed amount. After t hours the amount is the dose halved once for every half-life that has passed:
A = D × 0.5t ÷ h
Here D is the dose in milligrams, the preset or custom amount times the servings, and h is the half-life in hours. Solving the same curve for the moment it reaches your threshold gives the time the drink needs:
tbelow = h × log2(D ÷ threshold)
Added to the drink time, that gives the moment you drop below the threshold; subtracted from bedtime, it gives the latest time for the drink. The calculator works in whole minutes and rounds tbelow up to the next minute, so both clock times lean toward caution. A bedtime earlier on the clock than the drink is read as the next day's bedtime, and a bedtime equal to the drink time means drinking at bedtime. The comparison with your threshold uses the whole-milligram figure shown, so a Red Bull at the default times, 24.6 mg and shown as 25, counts as at the threshold. The table lists the amount at each whole hour after the drink until both bedtime and the crossing have passed, with at least two rows and at most 24.
A worked example
The defaults describe an afternoon cup: 95 mg of brewed coffee at 14:00, bed at 22:30, a 5-hour half-life and a 25 mg threshold. The wait is 8.5 hours, or 1.7 half-lives, and 0.51.7 ≈ 0.308, so about 31 percent of the dose remains: 95 × 0.308 ≈ 29 mg at bedtime, 4 mg above the threshold. The crossing takes 5 × log2(95 ÷ 25) = 5 × log2 3.8 ≈ 9.63 hours, which rounds up to 9 hours 38 minutes. Added to 2:00 pm, that puts you under 25 mg at 11:38 pm; taken from 10:30 pm, it makes 12:52 pm the latest time for the same cup. The table shows the halving directly: 48 mg at 7:00 pm, one half-life on, and 24 mg at midnight, two half-lives on. If you choose your bedtime by counting 90-minute sleep cycles, enter that time here and the cutoff moves with it.
From Goethe's coffee beans to a half-life
Caffeine's chemistry starts with an errand for Goethe. According to a 2017 history in the Pharmazeutische Zeitung, the pharmacist Friedlieb Ferdinand Runge, who took his medical doctorate in Jena in 1819, was invited that year to visit Johann Wolfgang von Goethe, who had heard that Runge could change a cat's eyes with henbane juice. Goethe sent him away with a box of coffee beans he had received from a Greek, to examine, and in 1820 Runge isolated the alkaloid caffeine from them. Seventy-five years later Emil Fischer and Lorenz Ach published a synthesis of the compound in the Berichte der deutschen chemischen Gesellschaft.
Later work measured how the body clears it. In a 1983 study, J. Blanchard and S. J. Sawers gave ten healthy young men a 5 mg/kg dose of caffeine by mouth and, on another occasion, by intravenous infusion, then measured their plasma levels for 24 hours. Oral absorption was very rapid, peaking after about 30 minutes, and essentially complete, yet individual half-lives ranged from 2.7 to 9.9 hours. In 1997 Kaplan and colleagues gave twelve volunteers 250 mg and 500 mg and found the kinetics nonlinear: at the larger dose, clearance fell and the half-life lengthened. A 2017 review by Temple and colleagues in Frontiers in Psychiatry put the adult half-life at 3 to 7 hours, with plasma levels peaking 15 to 120 minutes after ingestion.
The sleep evidence followed. In 2013 Drake and colleagues gave volunteers 400 mg of caffeine at bedtime, 3 hours before and 6 hours before; all three disturbed sleep compared with placebo, and the authors concluded that this supports avoiding substantial caffeine for at least 6 hours before bed. A 2023 meta-analysis of 24 studies by Gardiner and colleagues found caffeine cut total sleep time by 45 minutes and sleep efficiency by 7 percent, and it turned the results into timing rules: coffee with 107 mg per 250 mL at least 8.8 hours before bed, and a 217.5 mg standard serve of pre-workout supplement at least 13.2 hours before.
Why 25 mg, and why it is only a default
No study we found names a milligram level at which caffeine stops affecting sleep, so the threshold is yours to set. The nearest official statement is on the European Food Safety Authority's caffeine page: single doses of 100 mg "may affect sleep duration and patterns in some adults, particularly when consumed close to bedtime." That describes a fresh dose, not what is left of an afternoon cup.
The 25 mg default comes from our own arithmetic on Gardiner's two rules, a step the paper itself does not take. Run both through this model and they agree at a half-life of about 4.3 hours, where 107 mg after 8.8 hours and 217.5 mg after 13.2 hours each leave about 26 mg. At the default 5-hour half-life the same rules leave about 32 and 35 mg. A 25 mg threshold sits just under the 4.3-hour figures and well under the 5-hour ones: a stricter reading than the paper's, and a default rather than a recommendation. By the same model, Drake's 400 mg taken 6 hours before bed would still leave about 174 mg at lights out.
What the model leaves out
The result is milligrams in your body, not a blood level. Temple's review notes that caffeine reaches all body fluids, so a concentration would also depend on how much fluid the dose spreads through. The model also treats the drink as absorbed the moment you finish it; since plasma levels peak 15 to 120 minutes after ingestion, the real curve starts a little later than the one shown.
The half-life is the biggest unknown. The default of 5 hours is the midpoint of Temple's adult range, but the same review reports that oral contraceptives tend to double it, that pregnancy lengthens it by 8.3 hours on average, that liver disease can raise it, and that smoking doubles the rate of clearance. Nehlig's 2018 review traces much of the spread to the liver enzyme CYP1A2, which metabolizes 95 percent of the caffeine ingested and varies genetically. The FDA notes "wide variation in both how sensitive people are to the effects of caffeine and how fast they eliminate it from the body." At a 3-hour half-life the default coffee leaves 13 mg at bedtime; at 7 hours, 41 mg.
Large doses strain the model's central assumption: Kaplan's volunteers cleared 500 mg more slowly than 250 mg, so near the top of the range a first-order curve understates what is left, and the calculator refuses totals above 500 mg. Separate drinks simply add in this model, because each dose decays on its own: to include a morning coffee, run it separately and add the two bedtime figures.
The presets are typical figures, not your cup. Coffee, espresso and both teas come from USDA FoodData Central: brewed coffee at 40 mg per 100 g, espresso at 212, black tea at 20 and green tea at 12, times the database's portion weights, rounded to whole milligrams. Red Bull's product page gives 80 mg for an 8.4 fl oz can, ITO EN gives about 64 mg for a bowl of matcha made with 2 g of powder, and the pre-workout figure is Gardiner's standard serve. Real cups vary: the FDA's table of typical amounts puts 12 fl oz of regular brewed coffee at 113 to 247 mg, and home brew strength depends on how much ground coffee goes into each cup. The same table spans 41 to 246 mg for 12 fl oz of energy drink, so for other brands enter the figure printed on the can as a custom amount.
This page estimates caffeine with a simple model and is not medical advice. Pregnancy, medications and liver disease change how caffeine is cleared, so ask a doctor or pharmacist about your own limits. See the site disclaimer.
Frequently asked questions
How long does caffeine stay in your body?
It halves roughly every three to seven hours in healthy adults, the range given in a 2017 review by Temple and colleagues, so it lingers well after the buzz fades. At this calculator's default 5-hour half-life, a 95 mg cup of brewed coffee is down to about 48 mg after 5 hours and 24 mg after 10. After 20 hours, four half-lives, about 6 mg is left, a sixteenth of the dose.
How many hours before bed should I stop drinking coffee?
It depends on the dose and on how fast you clear caffeine. A 2023 meta-analysis by Gardiner and colleagues advised at least 8.8 hours for coffee with 107 mg per 250 mL and 13.2 hours for a 217.5 mg pre-workout serve, to avoid losing total sleep time. With this calculator's defaults, a 95 mg cup needs 9 hours 38 minutes to fall to 25 mg, so for a 10:30 pm bedtime the latest time to drink it is 12:52 pm. That is stricter than Gardiner's rule, because the 25 mg default is our own cautious choice, not a figure from the study.
How much caffeine at bedtime is too much?
No study we found sets a milligram level that is safe for sleep. The European Food Safety Authority says single doses of 100 mg may affect sleep duration and patterns in some adults, particularly when taken close to bedtime. The 25 mg default is an editorial choice based on our own arithmetic: at a 4.3-hour half-life, Gardiner's two timing rules both leave about 26 mg at bedtime. Set a different threshold if your own nights suggest one.
Why does caffeine keep some people awake longer than others?
Partly because people clear it at very different speeds. Nehlig's 2018 review says the liver enzyme CYP1A2 metabolizes 95 percent of the caffeine ingested and that a genetic polymorphism makes its pharmacokinetics highly variable. Temple's review adds that oral contraceptives tend to double the half-life, that pregnancy lengthens it by 8.3 hours on average, and that smoking doubles the rate of clearance. In a 1983 study of ten healthy men, half-lives ran from 2.7 to 9.9 hours.
Does this show the caffeine level in my blood?
No. It estimates how many milligrams of the dose are still in your body, not a concentration in plasma. Caffeine reaches all body fluids, so a blood level would also depend on how much fluid the dose spreads through, which the calculator does not ask about. The model also treats the drink as absorbed at once, while plasma caffeine actually peaks 15 to 120 minutes after drinking.
How much caffeine is in a cup of coffee?
USDA FoodData Central lists brewed coffee at 40 mg per 100 g, about 95 mg in an 8 fl oz cup and 142 mg in 12 fl oz, and espresso at 212 mg per 100 g, about 63 mg in a 1 fl oz shot. Real cups vary widely: the FDA's table of typical amounts puts 12 fl oz of regular brewed coffee at 113 to 247 mg. If you know your own drink's figure, choose the custom amount.
Sources
- The Safety of Ingested Caffeine: A Comprehensive Review, Frontiers in Psychiatry, 2017
- The effect of caffeine on subsequent sleep: A systematic review and meta-analysis, Sleep Medicine Reviews, 2023
- Caffeine, European Food Safety Authority
- Caffeine Effects on Sleep Taken 0, 3, or 6 Hours before Going to Bed, Journal of Clinical Sleep Medicine, 2013
- The absolute bioavailability of caffeine in man, European Journal of Clinical Pharmacology, 1983
- Dose-dependent pharmacokinetics and psychomotor effects of caffeine in humans, Journal of Clinical Pharmacology, 1997
- Interindividual Differences in Caffeine Metabolism and Factors Driving Caffeine Consumption, Pharmacological Reviews, 2018
- Spilling the Beans: How Much Caffeine is Too Much?, U.S. Food and Drug Administration, 2024
- Beverages, coffee, brewed, prepared with tap water (FDC ID 171890), USDA FoodData Central, 2019
- Beverages, coffee, brewed, espresso, restaurant-prepared (FDC ID 171891), USDA FoodData Central, 2019
- Beverages, tea, black, brewed, prepared with tap water (FDC ID 173227), USDA FoodData Central, 2019
- Beverages, tea, green, brewed, regular (FDC ID 171917), USDA FoodData Central, 2019
- The Original Red Bull: Red Bull Energy Drink, Red Bull
- How Much Caffeine is in Green Tea and Matcha?, ITO EN, 2026
- Synthese des Caffeïns, Berichte der deutschen chemischen Gesellschaft, 1895
- Coffein aus Goethes Kaffeebohnen, Pharmazeutische Zeitung, 2017