How this calculator works
Caffeine is absorbed quickly and then cleared by the liver at an exponential rate. A half life of five hours means that after five hours half the dose is still in the body, after ten hours a quarter, and after fifteen hours an eighth. Each drink adds a new dose on top of what remains from the drinks before it, so the level builds during the day and falls overnight. The chart starts at midnight and shows the level for the next 24 hours. The amount at bedtime is the figure that matters for sleep: caffeine blocks adenosine, the signal that builds up as a drive to sleep, and even a level that does not feel stimulating can make it harder to fall asleep. The half life is an input because it varies widely between people, and smokers, some medications and pregnancy change it.
Formula
caffeine at time t = sum over drinks of dose x 0.5^((t - time of drink) / half life), counting only drinks already taken. dose = caffeine per 100 mL x serving size / 100. The default half life is 5 hours. The chart plots the sum from midnight to the next midnight.
Worked example
Two 240 mL brewed coffees at 96 mg each, taken at 7:00 and 10:00, with a five hour half life. At 23:00 the first has decayed by 0.5^(16/5) = 0.108, leaving about 10 mg. The second has decayed by 0.5^(13/5) = 0.165, leaving about 16 mg. The total at bedtime is about 26 mg, well below 50 mg. Move the second coffee to 15:00 and it has decayed by 0.5^(8/5) = 0.33, leaving 32 mg, so the bedtime total rises to about 42 mg.
Advertisement
Frequently asked questions
Does caffeine really last that long?
In most adults the half life is about five hours, so a quarter of a coffee is still present ten hours later. That is why an afternoon coffee can disturb sleep even though the alert feeling has gone. The effect on a given person varies with genetics, smoking, pregnancy and some medicines.
What level should I aim for at bedtime?
There is no official threshold. Many sleep researchers use about 50 mg, roughly half a cup of coffee, as a level below which the effect on sleep is small for most adults. If you are sensitive, aim lower and keep the last drink earlier.
Does tolerance change how fast caffeine leaves?
Tolerance changes how much you feel from a dose, not how quickly the body clears it. A regular drinker may sleep badly on the same bedtime level as someone who never drinks coffee, but the half life is broadly the same.
Why is the chart only 24 hours?
The engine plots a fixed window and the question is about one day. If a drink is taken late at night, the curve after midnight is not shown, but the bedtime and below 50 mg figures still use the same decay, so the total effect is not lost.