Most people know not to have an espresso at 10pm. Far fewer know that the coffee at 4pm can still be in the room when you turn the lights off.
What the trial found
In a controlled study, healthy sleepers took caffeine at three different times — at bedtime, three hours before, and six hours before — and slept at home with a sleep monitor. Every timing disrupted sleep. Even the six-hour dose cut total sleep by more than an hour, and it flattened the slow brain waves of deep sleep.
One honest caveat: the dose was 400 mg — roughly four cups of brewed coffee at once. Smaller amounts do less. But the wider research points the same way: pooling 24 studies, people on caffeine took longer to fall asleep, spent more time awake in the night, and got less deep sleep.
Why it lasts so long
Through the day your brain builds up adenosine, a chemical that creates “sleep pressure” — the heavy, ready-for-bed feeling. Caffeine works by blocking adenosine’s receptors. It doesn’t remove the pressure; it hides it.
And it clears slowly. Caffeine’s half-life averages around five hours in healthy adults, and it varies a lot from person to person — from a couple of hours to well past eight. So half of that 3pm coffee can still be active around 8pm, and a quarter of it at 1am.
So where’s your cutoff?
A 2023 meta-analysis pooling the caffeine-and-sleep studies found caffeine cut total sleep by about 45 minutes on average, and suggested a standard cup of coffee should be finished around nine hours before bed to avoid that loss. Bigger doses, like pre-workout supplements, need even longer.
In practice, for an 11pm bedtime, that means your last coffee lands around 2pm. Treat that as a starting point, not a rule:
- Count all of it. Tea, cola, energy drinks and pre-workout all carry caffeine. Decaf carries a little.
- Run your own two-week test. Move your last coffee earlier and keep everything else the same. Sleep habits take a couple of weeks to settle, so give it time before you judge.
- Watch the nights, not one night. A single bad night is noise. A pattern across two weeks is a signal.
If you’re pregnant, take medication, or have a heart condition, caffeine guidance can be different for you — check with a professional.
How Biokei helps
Biokei pulls your sleep in automatically from Apple Health and lays it on one timeline with the rest of your day — so when you try an earlier cutoff, you can see what your nights actually did, instead of guessing.
Medical disclaimer: Biokei shows estimates to guide healthy habits, not medical advice.
- Drake C, et al. Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed. J Clin Sleep Med. 2013;9(11):1195-1200. pubmed.ncbi.nlm.nih.gov/24235903
- Gardiner C, et al. The effect of caffeine on subsequent sleep: a systematic review and meta-analysis. Sleep Med Rev. 2023;69:101764. doi.org/10.1016/j.smrv.2023.101764
- Institute of Medicine. Caffeine for the Sustainment of Mental Task Performance. National Academies Press. 2001. ncbi.nlm.nih.gov/books/NBK223808