
A friend of mine was averaging 4 cups of coffee a day. Morning espresso at 7. Drip coffee at 10. Post-lunch lungo at 14:00. And an afternoon ristretto around 16:00 "just to push through." He wasn't sleeping well, but blamed stress, screens, the usual suspects.
I told him to do the math.
The exponential decay you're ignoring
Caffeine follows first-order elimination kinetics with a half-life of approximately 5 hours in healthy adults. The formula is simple:
remaining = dose * 0.5 ^ (elapsed_hours / 5)
A single 95mg drip coffee at 10:00 AM leaves ~47mg by 3 PM and ~24mg by 8 PM. Sounds harmless. But most of us don't drink a single cup.
When you stack multiple intakes, the decay curves overlap. That 63mg espresso at 7 AM is almost gone by evening, but the 80mg lungo at 2 PM still has 40mg in your system at 9 PM. Add the 40mg ristretto at 4 PM and you're sitting at 64mg of caffeine at bedtime; well above the 50mg sleep disruption threshold identified in clinical research.
The problem isn't any single cup. It's the superposition of all of them.

Why I built a multi-intake caffeine tracker
Most caffeine calculators I found online only handle one beverage. You enter "95mg at 8 AM" and get a decay curve. Useless if you're a multi-cup person; which is most of us, according to the FDA's average of 3-4 cups per day in the U.S.
So I built one that handles the actual workflow: add as many beverages as you want, each with its own type and time, and see the combined decay curve.
The Caffeine Half-Life Calculator supports 11 beverage presets:
| Beverage | Caffeine (mg) |
|---|---|
| Ristretto | 40 |
| Espresso | 63 |
| Lungo | 80 |
| Drip Coffee | 95 |
| Cold Brew | 200 |
| Matcha | 70 |
| Energy Drink | 80 |
| Black Tea | 47 |
| Green Tea | 28 |
| Cola | 34 |
| Decaf | 7 |
You can also enter custom amounts. Everything runs client-side in the browser; no data leaves your machine.
The math behind the combined curve
For N intakes, the total caffeine at time T is:
total(T) = sum(dose_i * 0.5 ^ ((T - t_i) / 5)) for all i where T >= t_i
Each intake only contributes to the total after its consumption time. The resulting curve isn't a simple exponential; it's a sum of shifted exponentials, which can produce surprising plateaus when intakes are spaced closely.
This is why eyeballing it doesn't work. A 3 PM coffee "doesn't seem like much," but combined with the residual caffeine from morning drinks, it can push your bedtime levels past the threshold.

What we learned about his consumption
After plugging in his actual daily routine:
- 7:00 AM Espresso (63mg) ; mostly gone by evening; only 5mg left at 11 PM
- 10:00 AM Drip Coffee (95mg) ; still 17mg at 11 PM
- 2:00 PM Lungo (80mg) ; 28mg at 11 PM
- 4:00 PM Ristretto (40mg) ; 18mg at 11 PM
Total at 11 PM: 68mg. That's 36% above the sleep threshold.
Dropping the 4 PM ristretto brought him to 50mg; right at the edge. Moving the lungo to 1 PM dropped it to 43mg. That single hour shift made the difference.

The developer who also drinks cold brew
If you're a developer reading this; and statistically you probably are, given where I'm posting this; cold brew is particularly dangerous. At 200mg per serving, a single cold brew at 2 PM leaves 71mg in your system at 11 PM. By itself.
Add that to a morning coffee and you're looking at 80+ mg at bedtime. No wonder you're staring at the ceiling at 1 AM wondering if it's the code review or the caffeine.
Technical details
The tool is built with React, runs entirely in the browser (no backend), and uses URL state for shareability. The decay chart uses a simple bar visualization with color coding:
- Amber/dark: high caffeine (>50% of peak)
- Amber/light: moderate (below 50% of peak, above sleep threshold)
- Green: safe for sleep (below 50mg)
The source is part of Kitmul, a collection of 300+ free browser-based tools. If you're into health tracking, you might also find the BMI Calculator, BMR Calculator, or Water Intake Calculator useful; staying hydrated actually helps your body process caffeine more efficiently.
Practical takeaways
- Track all your intakes, not just the last one. Cumulative caffeine is what matters for sleep.
- The cutoff time depends on how many cups you've already had. A 2 PM coffee is fine after one morning cup, but not after three.
- Cold brew is not just "strong coffee." At 200mg it's in a different category entirely.
- Ristretto < Espresso < Lungo. Shorter extraction = less caffeine. If you want an afternoon coffee, go short.
- The 50mg threshold is a population average. If you're a slow metabolizer (CYP1A2 gene variant), your half-life could be 7+ hours. Adjust accordingly.
Try the Caffeine Half-Life Calculator with your actual daily intake. You might be surprised how much caffeine is still in your system at bedtime.
All calculations run locally in your browser. No data is sent anywhere. The tool is free, open, and has no accounts or limits.