Caffeine and Sleep: The Data on How Coffee Affects Your Rest

I drink four cups of coffee a day. I have done so since university. I also sleep 7.4 hours a night on average, with a resting heart rate of 52 bpm during deep sleep. For years, I told myself the caffeine didn't matter โ€” I was sleeping fine. Then I actually measured it, and the answer turned out to be more complicated than "coffee is bad" or "coffee is fine."

Over 60 days of controlled self-experimentation โ€” varying my last caffeine dose from 8am to 2pm, logging every milligram, and cross-referencing against my Oura data โ€” I built a picture of how caffeine actually interacts with my sleep. This article is everything I learned, combined with the research that explains why the data looked the way it did.

The Adenosine System: Why You Feel Sleepy in the First Place

Before we get into caffeine's pharmacology, you need to understand the system it's disrupting. Think of adenosine as your brain's sleep pressure meter.

Every second you're awake, your neurons consume energy. That metabolic process produces adenosine as a byproduct โ€” it literally accumulates in the spaces between your brain cells throughout the day. The more adenosine builds up, the sleepier you feel. This is why you're more tired at 10pm than at 10am, regardless of what you've been doing.

When you sleep, your brain clears adenosine. By morning, levels are back near zero and you feel refreshed. That's the whole system. It's elegant, it's ancient, and it works.

Caffeine works by sitting in adenosine receptors without activating them. It's like putting a key in a lock that doesn't turn โ€” it blocks the real key (adenosine) from getting in. Your brain still produces adenosine at the same rate, but you can't feel it. The sleep pressure is still building; you've just gone deaf to the alarm.

This is the critical distinction: caffeine doesn't eliminate sleep pressure. It masks it. When the caffeine wears off, you get hit with the accumulated pressure โ€” which is why the afternoon crash exists.

Caffeine's Half-Life: The Number That Matters

The half-life of a drug is how long it takes your body to eliminate 50% of it. For caffeine in a healthy adult, the average half-life is 5 to 6 hours. That's a widely accepted figure, and it means:

Twenty-five milligrams doesn't sound like much. But consider that a single espresso shot is about 63mg, and your brain is exquisitely sensitive to adenosine receptor blocking during sleep. Even small residual amounts can reduce deep sleep. A 2023 study in Sleep Medicine Reviews found that caffeine consumed 6 hours before bedtime reduced total sleep time by over 40 minutes on average.

My N=1 data: I tested this directly. Over two weeks, I drank my last coffee at noon (10 hours before bed). Average deep sleep: 1 hour 22 minutes. Over the next two weeks, I moved my last coffee to 2pm (8 hours before bed). Average deep sleep dropped to 1 hour 4 minutes โ€” a 22% decrease. Two cups of coffee, shifted by two hours, cost me 18 minutes of deep sleep per night. That's 126 minutes a week. Over a year, that's 109 hours of lost deep sleep.

CYP1A2: Why Your Mate Can Nap After an Espresso

Here's where individual variation makes the "5 to 6 hour half-life" number less useful than it seems. The enzyme that metabolises caffeine is called CYP1A2, and it's encoded by the CYP1A2 gene. Genetic variants in this gene produce dramatically different metabolisation speeds.

People fall broadly into two groups:

About 50% of the population are fast metabolisers, and roughly 10% are ultra-slow. If you've ever wondered why some people seem immune to caffeine's effects on sleep while you lie awake after a single afternoon cup, this is the most likely explanation. It's genetic, not psychological.

You can get CYP1A2 genotyped through consumer DNA tests like 23andMe or AncestryDNA, then check your raw data. It's a quick lookup. I did โ€” I'm a fast metaboliser, which explains why four cups a day hasn't wrecked my sleep. But I tested the timing effects anyway, because even fast metabolisers have a threshold.

The Cutoff Time Rule: Backed by Data

The research is consistent on one thing: the later your last caffeine dose, the worse your sleep quality. The specific timing depends on your individual metabolism, but here's a practical framework based on the pharmacology:

The key insight from my own data: it wasn't just the last cup that mattered โ€” it was the cumulative intake. Two coffees before noon hit differently than one coffee at noon. Caffeine from earlier doses hasn't fully cleared by the time you have the next one, so the effects stack. My worst sleep scores correlated not with late caffeine, but with total daily intake above 300mg regardless of timing.

Decaf Is Not Caffeine-Free (And It Matters)

This one surprises most people. A standard cup of decaf contains 7โ€“15mg of caffeine. That's not zero. It's also not trivial.

To put it in context: a typical decaf serving delivers about 10% of a regular cup's caffeine. If you drink two decaf coffees in the evening (a common pattern for people trying to "wind down"), that's 14โ€“30mg of caffeine โ€” roughly equivalent to half an espresso. For a slow metaboliser with bedtime at 10pm, that's enough to measurably affect sleep architecture.

And it gets worse. The decaffeination process removes 94โ€“98% of caffeine, not 100%. Swiss Water Process and COโ‚‚ methods are more thorough than chemical solvents, but none achieve complete elimination. A 2022 analysis found that the variation between decaf brands was significant โ€” some contained as little as 3mg per cup, others up to 15mg.

My rule: If caffeine is affecting your sleep, decaf is not a safe fallback after 6pm. Switch to herbal tea, which genuinely contains zero caffeine. It's a small change, but the data doesn't lie.

Caffeine Cycling: The Tolerance Problem

Your brain adapts to regular caffeine intake. Within about a week of daily consumption, adenosine receptors upregulate โ€” your brain literally grows more receptors to compensate for the constant blocking. This is tolerance, and it means your daily coffee is doing progressively less to make you feel alert while doing progressively more to disrupt your sleep.

Caffeine cycling is the strategy of periodically reducing or eliminating caffeine to reset those receptors. The common approach:

I run a two-week complete reset every six months. The first three days are miserable โ€” genuine withdrawal headaches, brain fog, reduced motivation. By day five, I feel normal. By day fourteen, I reintroduce coffee and the effect is striking. A single cup feels like two used to. My Oura data during the reset period shows consistently higher deep sleep percentages, suggesting that my "normal" caffeine habit was suppressing deep sleep in ways I'd normalised.

The research backs this up. A 2021 crossover study in the Journal of Clinical Sleep Medicine found that regular caffeine users who completed a 4-week withdrawal period showed a 15% increase in slow-wave (deep) sleep compared to their baseline.

Practical Caffeine Rules: What I Actually Follow

After 60 days of testing and three years of tracking, these are the rules that have survived contact with reality:

These rules aren't arbitrary. Each one maps directly to data I collected. The 1pm cutoff exists because my deep sleep dropped measurably when I pushed it to 2pm. The 300mg ceiling exists because my sleep onset time increased by 8 minutes on average above that threshold. The resets exist because my tolerance clearly crept up over six months, and the data confirmed it.

The Bigger Picture

Caffeine is a remarkable tool. It enhances focus, improves reaction time, and โ€” in moderate doses โ€” has genuine health benefits including reduced risk of Parkinson's, type 2 diabetes, and certain cancers. I'm not anti-caffeine. I'm anti-caffeine-ignorance.

The problem isn't drinking coffee. It's drinking coffee without understanding the pharmacology, ignoring your genetic profile, and then wondering why you can't fall asleep or why your sleep quality feels degraded. The data is clear: caffeine timing and dose matter far more than most people realise, and the effects are cumulative and individual.

My four-cups-a-day habit survived because I'm a fast metaboliser who times his intake carefully. If I were a slow metaboliser? I'd probably be down to one cup, consumed before 10am. The right answer is personal, but the method for finding it is universal: measure, adjust, measure again.

Related reading: Sleep Trackers Explained ยท Sleep Hygiene Checklist ยท Why Am I Tired All The Time? ยท Perfect Bedtime Routine

๐Ÿ‘จโ€๐Ÿ’ป
Tom Richards

Software engineer and self-described data nerd based in Cambridge. Tom has tracked over 1,000 nights of sleep with consumer wearables and writes about the intersection of technology, data, and sleep. He's not a sleep scientist โ€” he's the first to say that โ€” but he builds a very thorough spreadsheet.

Disclosure: SleepWell UK is reader-supported. When you buy through links on our site, we may earn an affiliate commission. This comes at no extra cost to you and helps us keep providing free, independent advice. We never accept paid placements or sponsored reviews. Read our full affiliate disclosure.

๐ŸŒ™ Sleep Better Every Week

Get our best sleep tips, product deals, and expert advice delivered to your inbox.