How does the caffeine calculator work?

It uses the half-life of caffeine: the time your body takes to clear half of it. A 2024 review in the International Journal of Molecular Sciences puts it "within 3 to 5 h" for adults. The calculator runs every drink through both ends of that range and the middle, so you get an estimate with an honest spread rather than one number that looks more precise than it is.

  1. Set your bedtime. Use the time you usually turn the light off, not the time you get into bed.
  2. Add each caffeinated drink and when you had it. The presets use FDA figures, and you can type in the number from your own drink's label instead.
  3. Read the estimate. It shows roughly how much caffeine is left at bedtime and compares it with a familiar drink.
  4. Check your cutoff. The two times at the bottom show when your last caffeine should be to leave five hours before bed, the CDC minimum, or six hours for more margin.

The example already filled in is a 12 fl oz coffee at 8am and a black tea at 3:30pm, with a 10:30pm bedtime. It works out at roughly 20 to 51 mg still in your system at lights out, around a green tea's worth, from two drinks that most people would call perfectly reasonable.

How long does caffeine stay in your system?

Longer than most people assume. With a half-life of 3 to 5 hours, a quarter of the caffeine from a drink is still there 6 to 10 hours later, and an eighth after 9 to 15 hours. Here is how a 180 mg brewed coffee fades at each end of that range:

Hours after drinkingLeft if it halves every 3 hoursLeft if it halves every 5 hours
0180 mg180 mg
390 mg119 mg
645 mg78 mg
922 mg52 mg
1211 mg34 mg

The same review notes that peak levels in the blood arrive somewhere between 15 and 120 minutes after drinking, and that "it takes about an hour for plasma concentrations to peak". The calculator counts each drink from the moment you had it, so for a drink close to bedtime the real figure can be a little higher than the estimate.

Why is the estimate a range?

Because people genuinely differ. 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."

Some of that variation has known causes. A 2022 systematic analysis in Frontiers in Pharmacology, which pooled data from 141 studies, reports that smoking increases caffeine clearance and shortens its half-life, while "Oral contraceptive use has the opposite effect". It also lists pregnancy among the factors that change how caffeine is processed. So if you use hormonal contraception, the slower end of the estimate is likely closer for you. If you are pregnant, follow the advice of your midwife or doctor rather than this calculator.

When should you stop drinking caffeine before bed?

At least five hours before, and six gives you more margin. The CDC's workplace health institute, NIOSH, advises avoiding caffeine, chocolate and nicotine "for 5 or more hours before sleep is planned", and for longer if you are sensitive.

The case for six comes from a controlled trial in the Journal of Clinical Sleep Medicine. A 400 mg dose of caffeine taken 6 hours before bed still cut objectively measured sleep by more than an hour, even though participants' own sleep diaries did not clearly pick it up. It was a small study of 12 people using a large dose, but it shows why feeling fine is not a reliable guide. Put 400 mg into the calculator six hours before bed and it estimates 100 to 174 mg still in your system at lights out.

For the full picture of what caffeine does to a night's sleep, read how long caffeine affects sleep.

How much caffeine is in your drink?

Less predictable than the cup suggests. These are the FDA's figures per 12 fl oz, which the calculator uses as starting points:

DrinkCaffeine
Brewed coffee113 to 247 mg
Black tea71 mg
Green tea37 mg
Caffeinated soft drink23 to 83 mg
Energy drink41 to 246 mg
Decaf coffee, per 8 fl oz2 to 15 mg

Where the FDA gives a range, the calculator starts at the midpoint. If your drink has a label, or the coffee shop publishes a figure, type that in instead. For context, the FDA cites 400 mg a day as "an amount not generally associated with negative effects" for most adults. That figure is about daily intake, not sleep: a much smaller amount late in the day can still leave caffeine in your system at bedtime.

What can the calculator not tell you?

  • Your own half-life. The estimate spans the range reported for adults. Where you sit in it is not something a calculator can know.
  • Exactly what was in your cup. Brewing method, cup size and beans all change the figure.
  • How sensitive you are. Two people with the same amount left can sleep very differently.
  • The timing of absorption. Each drink is counted from the moment you had it, which slightly underestimates a drink close to bedtime.

If you move your last caffeine to a sensible cutoff and still struggle to sleep, caffeine was probably not the main problem. Read why you cannot fall asleep, use the sleep calculator to plan enough sleep, or find out whether caffeine actually gives you energy.