Caffeine Calculator


When to stop drinking coffee and tea, based on sleep research

Work out the latest time to have your coffee and tea before bed, using cut-offs from sleep research. Adjust the inputs and everything recalculates instantly. If you like to time caffeine around your cortisol rhythm, the graph also shows optional preferred windows.

I built this to stop my afternoon coffee costing me sleep. To quote Tim Ferriss: "I am not a doctor, and I don't play one on the internet." This is not medical advice.

Last coffee by
--:--
Last tea by
--:--
Left at bedtime
-- mg
Cortisol
Caffeine in system
Coffee cut-off
Tea cut-off
Preferred window
Too late

How this works

Cortisol rhythm: Your body produces cortisol in peaks throughout the day, starting with the cortisol awakening response about 30-45 minutes after you wake up, with smaller peaks in the late morning and mid-afternoon. Some people prefer to wait until after the cortisol awakening response before their first coffee. The evidence for this is thin, so treat the green windows as a preference, not a rule.

Caffeine half-life: The average adult eliminates half the caffeine in their system every 5 hours. Smokers clear it faster, in about 3 hours. Slow metabolisers take around 8 hours (oral contraceptives raise it from roughly 5 to 8 hours), and pregnancy slows it much further. The metabolism setting stretches or shortens the cut-off times in proportion.

When to stop: Gardiner et al. (2023, Sleep Medicine Reviews) reviewed the evidence on caffeine and the sleep that follows it. To avoid losing total sleep time, they recommend a 107 mg coffee at least 8.8 hours before bed and 217.5 mg at least 13.2 hours before bed. This tool draws a straight line between those two points, so each drink gets its own gap: at normal metabolism a coffee (95 mg) needs about 8.3 hours and a tea (47 mg) about 6.4 hours. Your bedtime minus that gap gives the "Last coffee by" and "Last tea by" times, and no drink is scheduled after its cut-off. Read the paper (opens in a new tab).

Drink placement: By default, coffees are placed in earlier optimal windows (higher caffeine, more time to clear) and teas in later windows (lower caffeine, needs less clearance time). Drinks are kept at least 30 minutes apart. Use the drink order selector to change this if you prefer tea in the morning.

Yesterday's carry-over: Caffeine doesn't fully clear overnight. With a 5-hour half-life, a drink at 14:00 still leaves a few milligrams in your system 17 hours later at 07:00. Toggle this on to see the residual from an identical previous day's schedule layered into the curve. It's often 15-25 mg but adds up for slow metabolisers or heavy drinkers.

Assumptions: The tool assumes 95 mg per coffee (a mug of filter coffee) and 47 mg per tea. A UK instant coffee is often nearer 60-80 mg, and a high-street flat white can be 130 mg or more.

This is a simplified model. Individual responses to caffeine vary based on genetics, tolerance, medications, and other factors. Use it as a guide, not gospel.

More tools