Most people who drink coffee already suspect it affects their sleep. What is harder to know is how much, and how late is actually too late. The folk rule of “no coffee after lunch” and the opposite claim, “caffeine never bothers me,” both survive because the effect is easy to misjudge from the inside.
This page goes through the research that put numbers on it: a 2023 meta-analysis of 24 studies, a double-blind trial that tested a 400 mg dose at three different times before bed, and the cut-off advice from the Sleep Foundation. Then it turns those numbers into a worked example so you can pick a cutoff time that fits your own bedtime. It is an explainer about published research, not medical advice, and it cannot diagnose a sleep problem.
If your main worry is that the jitters or racing thoughts you feel are the caffeine itself, our coffee and anxiety guide covers that side. This page is about the night, not the afternoon.
The short version
- A 2023 systematic review and meta-analysis of 24 studies found caffeine reduced total sleep time by 45 minutes and sleep efficiency by 7 percent.
- The same analysis found sleep onset took 9 minutes longer, time awake after falling asleep rose by 12 minutes, and deep sleep (N3 and N4) fell by 11.4 minutes.
- In a double-blind trial of 400 mg of caffeine, doses taken at bedtime, 3 hours before bed and 6 hours before bed each significantly disturbed sleep compared with placebo.
- Press coverage of that trial reported 12 healthy sleepers, more than an hour of lost sleep at the 6-hour mark, and participants who did not notice the disruption.
- The Sleep Foundation gives caffeine a half-life of anywhere between 2 and 12 hours and recommends a cut-off of at least 8 hours before bedtime.
- The meta-analysis suggests that a cup of coffee (107 mg per 250 mL in its calculation) should be finished at least 8.8 hours before bed.
- Individual sensitivity varies a lot, so these are population figures, not a guarantee for you.
Why caffeine and sleep collide

Caffeine does not give you energy. It blocks the receptors that adenosine uses to tell your brain it has been awake a long time. The pressure to sleep still builds, but you feel it less. Our caffeine withdrawal timeline covers the rebound that follows when the blocker is removed after months of regular use.
The part that matters for sleep is how long the blocker lasts. The Sleep Foundation puts the effects as starting after around 30 minutes and lasting up to five hours or longer, with a half-life of anywhere between 2 and 12 hours depending on the person. Genetics, nicotine use, pregnancy status and how often you consume caffeine all change how quickly it clears. That range is wide enough that two people can drink the same 3 pm cup and have very different nights.
What the 2023 meta-analysis found
Gardiner and colleagues published their review in Sleep Medicine Reviews in June 2023. It pooled 24 studies that compared sleep after caffeine with sleep after a control, which makes it a better guide to the average than any single trial.
The headline numbers

| Sleep measure | Effect of caffeine |
|---|---|
| Total sleep time | 45 minutes less |
| Sleep efficiency | 7 percent lower |
| Time to fall asleep (sleep onset latency) | 9 minutes longer |
| Time awake after sleep onset | 12 minutes longer |
| Deep sleep (N3 and N4) | 11.4 minutes less, and 1.4 percentage points lower as a proportion |
| Light sleep (N1) | 6.1 minutes more, and 1.7 percentage points higher as a proportion |
Two things are worth noticing. First, the biggest effect is not in how long it takes to fall asleep, which is where most people look for it. It is in total sleep time and in the quality of what you do get: less deep sleep and more light sleep. Second, these are averages across different doses and timings, so some of the studies in the pool will have used more caffeine than a single cup.
The timing guidance
The authors went one step further and estimated how long before bed different caffeine sources should be consumed. For coffee, using 107 mg per 250 mL, they suggested at least 8.8 hours before bedtime. For a pre-workout supplement at 217.5 mg, the figure was at least 13.2 hours. Those are model-based suggestions from pooled data, not a rule that every drinker needs. They are a sensible starting point though, because they follow from the dose. If you are lifting after work, our coffee before a workout guide covers the timing side from the exercise angle.
The trial that tested the afternoon cup
The meta-analysis tells you about averages. The Drake trial tells you what a single afternoon dose does, and it is the study most often cited for the “even six hours is too close” claim.
What the trial did
Drake, Roehrs, Shambroom and Roth published in the Journal of Clinical Sleep Medicine in 2013. It was a randomised, double-blind, placebo-controlled study. Participants took 400 mg of caffeine at bedtime, 3 hours before bedtime or 6 hours before bedtime, and the results were compared with placebo. Sleep was measured both by self-report and by a validated portable sleep monitor.
What it found
According to the abstract, caffeine at bedtime, 3 hours before bedtime and 6 hours before bedtime each had significant effects on sleep disturbance relative to placebo (p below 0.05 for all). The authors concluded that caffeine taken 6 hours before bed has important disruptive effects on total sleep time.
Press coverage of the study from the time, which we could not cross-check against the full paper because the journal and PubMed Central pages were blocked to our fetch tool, reported 12 healthy normal sleepers, more than one hour of lost sleep at the 6-hour mark, and participants who did not notice the disturbance in their own ratings. If that last detail is right, it is the most useful finding for everyday life: you can lose sleep to a late cup without feeling that you did.
How to read it
400 mg is a large dose, roughly what the Mayo Clinic describes as four cups of brewed coffee. A single small cup at the same time would likely do less. The sample was small, the participants were healthy sleepers, and the trial did not test regular habitual drinkers separately from occasional ones. Treat it as evidence that the afternoon matters, not as a measurement of exactly how much one cup costs you.
Why you might not feel it
There is a practical reason the sleep cost of coffee is easy to underestimate. The usual test people apply to themselves is “did I fall asleep okay?” Sleep onset only moved by 9 minutes in the meta-analysis, which is hard to detect. The larger effects, less total sleep, less deep sleep, more waking in the night, are exactly the ones you do not remember in the morning.
Habit can also blur the signal. Regular drinkers tend to feel tired and low as soon as the caffeine wears off, and that tiredness can be read as “I need coffee” rather than “I slept badly.” The Mayo Clinic notes that how you react to caffeine may depend partly on how much you are used to drinking, and that people who do not regularly drink caffeine tend to be more sensitive to its effects.
A worked example: setting your cutoff

Here is a simple way to turn the research into a time on the clock. This is our suggestion for applying the figures, not a protocol from a trial.
Step 1: find your bedtime. Say you go to bed at 11 pm.
Step 2: count back. The Sleep Foundation’s minimum of 8 hours gives a 3 pm cutoff. The meta-analysis figure of 8.8 hours for a cup of coffee gives roughly 2:15 pm. The Sleep Foundation also notes that some people may benefit from 10 hours or more, which would be 1 pm.
Step 3: pick a window, not a minute. For a first week, try 2 pm. It sits between the two published figures.
Step 4: see how much is left at bedtime. Take a 200 mg afternoon intake at 3 pm. If your half-life were 5 hours, which is within the 2 to 12 hour range the Sleep Foundation gives, about 100 mg would remain at 8 pm and about 50 mg at 1 am. That is an illustration of the arithmetic, not a measurement of anyone’s body. If your half-life is closer to 10 hours, about 140 mg would still be in your system at 8 pm.
Step 5: judge the result by more than falling asleep. For one week, note how you feel on waking and how often you remember waking in the night. If both improve with an earlier cutoff, that is your answer. If nothing changes, your personal sensitivity may be lower than average, and you can move the cutoff later in half-hour steps.
What counts as caffeine in the afternoon
The cup you pour is not the only source. A mug of filter coffee is larger than the 250 mL used in the meta-analysis calculation, and the figures there are for coffee at 107 mg per 250 mL. Our americano versus long black versus filter coffee guide cites 96 mg per 8-ounce filter cup, and our caffeine in an espresso shot page shows how much espresso varies. Tea, cola and pre-workout powders add to the same total.
What about decaf?
Decaf is not caffeine-free, so a late cup is not zero risk, but it is a large reduction. Our decaf coffee caffeine content guide gives the per-cup figures. We did not find a sleep trial in the sources used here that tested decaf directly, so we are not claiming a measured sleep benefit from switching, only that it removes most of the caffeine dose.
Practical takeaways
- Count back at least 8 hours from bedtime. That is the Sleep Foundation’s minimum, and the 2023 meta-analysis points to around 8.8 hours for a cup of coffee.
- Do not trust “I fall asleep fine.” The biggest effects in the data are on total sleep and deep sleep, not on how fast you drop off.
- Watch the total, not just the cup. Mayo Clinic’s 400 mg guideline is for the whole day, and sleep problems are one of the effects it lists above that level.
- Test your own cutoff for a week. Half-lives range from 2 to 12 hours, so a population average can miss you in either direction.
- If you cut back hard, expect a rebound. See our caffeine withdrawal timeline for what to expect and how long it lasts.
- Stress can look like caffeine. Our coffee and cortisol guide covers the stress-hormone side of the afternoon cup.
Common mistakes
Judging by sleep onset alone. The meta-analysis found only 9 extra minutes to fall asleep, but 45 fewer minutes of total sleep.
Treating the cutoff as one number for everyone. The half-life range of 2 to 12 hours means the right cutoff for one person is wrong for another.
Forgetting that cutoffs are measured from bedtime, not wake time. A late bedtime moves the cutoff later too, and an early one moves it earlier.
Counting only coffee. Tea, cola, chocolate-heavy desserts and pre-workout powders also contribute, and the meta-analysis gave a longer cutoff for a 217.5 mg pre-workout than for coffee.
Assuming a sleepy morning means you need more coffee. It may mean the previous afternoon’s cup cost you sleep.
Common questions
How long before bed should you stop drinking coffee? The Sleep Foundation recommends a minimum of eight hours before bedtime, with some people benefiting from ten hours or more. The 2023 meta-analysis suggested at least 8.8 hours for a cup of coffee at 107 mg per 250 mL.
Does coffee at 3 pm affect sleep at 11 pm? Possibly. In the Drake trial, a 400 mg dose taken 6 hours before bed significantly disturbed sleep compared with placebo. A smaller dose would likely do less, and individual sensitivity varies.
How long does caffeine stay in your system? The Sleep Foundation gives a half-life of anywhere between 2 and 12 hours, with effects typically starting after around 30 minutes and lasting up to five hours or longer.
How much sleep does caffeine cost you? The 2023 meta-analysis of 24 studies found an average reduction of 45 minutes in total sleep time and 7 percent in sleep efficiency. That is an average across different doses and timings.
Can you drink coffee and still sleep well? Many people can, mainly by keeping a cutoff well before bed and staying under about 400 mg a day, the level Mayo Clinic says appears safe for most healthy adults. Some people are more sensitive and need an earlier cutoff.
Does decaf affect sleep? Decaf still contains a small amount of caffeine, and we did not find a sleep trial on it among our sources. It removes most of the dose, but it is not zero.
Why do I feel fine but sleep badly after afternoon coffee? The sleep effects in the research are mostly on total sleep time and deep sleep, which are hard to notice. Press coverage of the Drake trial reported that participants did not perceive the disruption from a dose taken six hours before bed.
Is it better to quit coffee for better sleep? You do not have to quit. Moving your last cup earlier gets most of the benefit in the research for most people, and it avoids the withdrawal symptoms described in our withdrawal guide. If you have a diagnosed sleep disorder, ask your doctor.
Sources & data
- Gardiner C et al.: The effect of caffeine on subsequent sleep, a systematic review and meta-analysis (Sleep Medicine Reviews, June 2023; PubMed 36870101)
- Drake C, Roehrs T, Shambroom J, Roth T: Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed (Journal of Clinical Sleep Medicine, 2013; PubMed 24235903)
- Sleep Foundation: Caffeine and sleep (half-life and cut-off timing)
- Mayo Clinic: Caffeine, how much is too much?



