How this calculator works
This tool plans when to have caffeine around the times you need to be alert and the time you go to bed. It works in two steps:
- Timing: each drink is placed about 45 minutes before its window, so caffeine is near its peak when the window starts. The 45 minutes is our assumption: studies report peak blood levels from about 30 minutes to 2 hours after drinking.
- A range, not one number: caffeine's half-life averages about 4 hours in healthy adults and ranges from about 2 to 8 hours (EFSA). The tool shows what is left at bedtime for a fast (3 h), average (5 h) and slow (8 h) half-life, and adds up every drink of the day.
It aims for 50 mg or less at bedtime. That target is our modelling choice, not a published limit: at the tool's 5-hour average half-life, 100 mg falls to about 57 mg four hours later, and 100 mg four hours before bed is a dose and timing that had no significant effect on sleep in a 2025 trial in 23 healthy young men.
Key evidence
- Gardiner et al. 2025 (randomized trial, 23 healthy young men): 100 mg had no significant effect on sleep when taken 12, 8 or 4 hours before bed. 400 mg reduced deep sleep at all three timings and cut total sleep by about 50 minutes when taken 4 hours before bed.
- Gardiner et al. 2023 (meta-analysis): to avoid losing sleep time, the authors suggest having a coffee (107 mg per 250 ml) at least 8.8 hours before bed and a pre-workout serving (217.5 mg) at least 13.2 hours before bed.
- Drake et al. 2013 (J Clin Sleep Med, 12 people): 400 mg taken 6 hours before bed cut sleep measured by a monitor by more than an hour; in participants' own sleep diaries the loss was smaller and not statistically clear.