That afternoon coffee is still with you at midnight
Caffeine doesn't disappear when you stop feeling it. With an average half-life of 5 hours, a 150 mg coffee at 8:30 AM and another at 2:00 PM still leave about 63 mg in your body at 11:00 PM.
Flip it around: to fall asleep at 11:00 PM with less than 50 mg on board, if it's your only cup today, finish a 150 mg coffee by 3:05 PM. A big 250 mg cup moves the deadline up to 11:23 AM; an 80 mg small one can wait until 7:37 PM. If you already had coffee this morning, the deadline comes even earlier — the calculator handles that for you.
How it's calculated
- Caffeine left from a cup at time t = mg × 0.5 ^ (hours elapsed ÷ half-life)
- Caffeine at bedtime = the sum of what's left from every cup
- Single-cup deadline = bedtime − half-life × log₂(cup mg ÷ target)
- One-more-cup deadline = bedtime − half-life × log₂(cup mg ÷ (target − what's left from today's cups))
The model assumes caffeine is absorbed instantly and cleared at a constant rate. In reality it starts working about 15 to 30 minutes after you drink it (EFSA), so treat the result as an estimate. Cups scheduled after bedtime aren't counted.
What the research says
In a 2013 study in the Journal of Clinical Sleep Medicine, people took 400 mg of caffeine 0, 3, or 6 hours before bed. Even the 6-hour group had noticeably disrupted sleep. The European Food Safety Authority also notes that 100 mg close to bedtime can affect sleep in some adults.
Sleep well and still drink coffee
- Front-load your caffeine. The same cup in the morning leaves far less at bedtime than one in the afternoon.
- Go smaller after lunch. Halve the caffeine and your deadline moves back by one half-life.
- Count tea, soda, and energy drinks. They all contain caffeine, too.
- Watch your daily total. The FDA has cited 400 mg a day as an amount not generally linked to negative effects for most healthy adults.