Daily Rituals
How Long Before Bed Should You Stop Drinking Coffee?
There is no single cut-off time, because how much you drink matters more than when. In one trial, a small coffee four hours before bed had no measurable effect on sleep at all, while a large dose cost around fifty minutes of sleep at the same timing and still hurt sleep quality eight hours out. The part worth knowing: in another trial, people who drank caffeine six hours before bed lost over an hour of sleep and their own sleep diaries showed nothing wrong. You cannot feel this happening, which is why "coffee doesn't affect me" is so common and so unreliable. Caffeine also clears at very different speeds — roughly two to ten hours to halve, depending on the person — so the honest answer is that a small coffee in the afternoon is usually fine, a large one is the thing to move earlier, and the only way to know your own number is to change one thing and watch what happens.
Most advice on this comes down to a number someone made up. No coffee after 2pm. Or midday. Or noon on weekdays and whenever you like on holiday.
The research points somewhere more useful, and slightly annoying: how much you drink matters more than when you drink it.
So how late is too late?
Two good trials have asked this properly, by giving people caffeine or a dummy pill at set times and then measuring their sleep rather than asking about it.
A small coffee — around 100 mg — had no measurable effect on sleep at any timing tested, including four hours before bed.
A large dose, around 400 mg, was a different story. Four hours before bed it cost about fifty minutes of sleep. Eight hours before bed it was still measurably reducing sleep quality. In the other trial, 400 mg six hours before bed cut more than an hour from total sleep.
So “is 4pm too late?” is the wrong question. The better one is: how big is it?
A useful way to hold this: the amount officially considered fine for a whole day is roughly the amount that wrecks a night if you drink it in one go. The US food regulator puts 400 mg a day as safe for most adults. That is also the dose both trials used to disrupt sleep.
Why you cannot tell whether it is affecting you
This is the part most people have never heard, and it changes how much to trust your own experience.
In the six-hour trial, the measurements showed over an hour of lost sleep. The participants’ own sleep diaries showed nothing. They did not notice.
The researchers were explicit about it: people lack awareness of caffeine-induced sleep disruption, and that is probably why advice about caffeine timing gets ignored so widely. Everyone has met someone who says coffee doesn’t affect them, usually while holding one at 9pm. They may be right. They may also be exactly the person in that trial.
Which means “I sleep fine after coffee” is not evidence of much. It is how it feels, and feeling is the thing that was shown not to track reality.
How long does caffeine actually stay in you?
On average, it takes about five hours for the amount in your body to fall by half. After ten hours, a quarter is still there.
But the average hides most of the story. Across healthy adults, that half-way point runs from about two hours to about ten. A fivefold difference, for the same drink.

Nine hours after the same coffee, one person is nearly clear and another still has close to half of it in them. Neither is doing anything wrong.
What shifts you along that range:
- Smoking speeds caffeine clearance up substantially.
- The contraceptive pill slows it down — in one study it took around ten and a half hours to halve, against just over six in women not taking it.
- Pregnancy slows it considerably.
- Genetics account for a good deal of the rest, which is why this runs in families.
If you are a slow clearer, the standard advice was never written for you.
How much is actually in your drink
Per 12-ounce cup, from the US food regulator:
| Drink | Caffeine |
|---|---|
| Brewed coffee | 113–247 mg |
| Energy drink | 41–246 mg |
| Black tea | 71 mg |
| Cola | 23–83 mg |
| Green tea | 37 mg |
Two things stand out. A coffee can hold more than twice as much as another coffee of the same size, so “two coffees” could mean 226 mg or 494 mg. And a large takeaway cup is usually bigger than 12 ounces, which makes it bigger than the figure above.
Most people who are surprised by their intake are not drinking more cups than they thought. The cups are just bigger than they thought.
If you get anxious, this is a different question
Caffeine does the same things to your body that anxiety does: faster heart rate, more alert, a bit jittery. If you are already prone to reading those signals as danger, that is an unhelpful combination.
In healthy people, caffeine measurably raises anxiety, and more so at higher doses.
For panic attacks the effect is much starker. When researchers gave large doses of caffeine to people with panic disorder, around half had a panic attack. Nobody given a dummy pill did.
That is worth knowing if you have ever had a panic attack and could not work out what set it off. It does not mean you must give up coffee. It means caffeine belongs on the list of things to look at, rather than being assumed harmless because it is ordinary.
If this sounds familiar, our guide to managing mild anxiety without medication covers the wider picture.
What to actually do
- Move the big one, not every one. The large morning coffee is rarely the problem. The large afternoon one is. Shrinking it often works better than shifting it.
- Know what you are actually drinking. One large takeaway coffee can be two or three cups’ worth. Check once; it is usually a surprise.
- Treat eight hours as the cautious line for a big dose, and about four for a small one. If you sleep badly anyway, start at the cautious end.
- Do not trust how you feel about it. That is the one thing the research is clear you cannot rely on.
- Change one thing at a time. Moving your cut-off, switching to decaf after lunch, or halving the size — pick one and give it two weeks.
- If you get panic attacks, test it deliberately. Cut right back for a fortnight and see.
If you are already awake at 3am regularly, caffeine is one of the first things worth ruling out — our guide on what to do when you wake at 3am covers the rest.
Working out your own number
Because the range between people is so wide, general advice can only get you close. Your number depends on how fast you clear it, how much you actually drink, and how well you sleep to begin with.
The only way to find it is to change one thing and watch what happens — and to write it down, because this is precisely the kind of effect you cannot detect by memory. The nights are too similar and the difference is too small to feel.
Note what you drank and when, roughly how you slept, and how the next day went. Two weeks of that will usually tell you more than any article can.
Logging how you feel each day, as you can in Moodify, makes that comparison easier to see than trying to hold it in your head. A note on your phone works too. The point is having something to look back on that is not your memory of how you think you slept.
Common questions
- How many hours before bed should you stop drinking coffee?
- There is no single number, because the dose matters as much as the timing. Research suggests a small coffee of around 100 mg can be fine up to about four hours before bed, while a large dose of around 400 mg is better avoided for much of the day — one trial found it still reduced sleep quality eight hours beforehand. If you want one rule, make it about size rather than the clock: keep the big drinks to the morning.
- Why do I sleep fine after coffee?
- You may not be. In one trial, people who took caffeine six hours before bed lost more than an hour of sleep when it was measured, but their own sleep diaries showed nothing unusual. The researchers described this as a lack of awareness of the disruption, and suggested it is why people ignore advice about caffeine timing. Feeling fine is not good evidence either way.
- How long does caffeine stay in your system?
- Caffeine takes about five hours on average to fall by half, but that figure varies a lot between people — published values in healthy adults range from roughly two hours to ten. Smoking speeds it up. Some medications, including the contraceptive pill, slow it down considerably. So the same afternoon coffee can leave one person almost clear by bedtime and another with half of it still on board.
- Can caffeine make anxiety worse?
- Yes, and the effect gets larger with the dose. It matters most for people who have panic attacks: when studies gave people with panic disorder a large dose of caffeine, around half had a panic attack, while nobody did on a dummy pill. If you get panic attacks, caffeine is worth treating as a specific trigger rather than a general health question.
- How much caffeine is in a cup of coffee?
- A 12-ounce cup of ordinary brewed coffee contains roughly 113 to 247 mg, according to the US Food and Drug Administration — so the amount in "a coffee" can nearly double depending on where you buy it. Black tea is about 71 mg for the same size, green tea about 37 mg, cola between 23 and 83 mg, and energy drinks anywhere from 41 to 246 mg.
- Does switching to decaf in the afternoon help?
- It can, and it is usually easier than quitting. Decaf is not caffeine free, but the amount is small enough that it is unlikely to matter for sleep. If you like the ritual of an afternoon coffee more than the effect, swapping the drink rather than dropping it tends to last longer than going cold turkey.
Sources
- Drake, Roehrs, Shambroom & Roth — Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed (Journal of Clinical Sleep Medicine, 2013)
- Gardiner et al. — Dose and timing effects of caffeine on subsequent sleep: a randomized clinical crossover trial (Sleep, 2024)
- US Food and Drug Administration — Spilling the beans: how much caffeine is too much?
- Effects of caffeine on anxiety and panic attacks in patients with panic disorder: a systematic review and meta-analysis (2022)
- Caffeine intake and anxiety: a systematic review and meta-analysis (Frontiers in Psychology, 2024)
- US National Institute of Mental Health — health topics
General information, not medical advice. See our editorial policy for how these guides are written and corrected.