Short answer: a 2023 meta-analysis of 24 studies found that a regular cup of coffee (about 107 mg of caffeine) should be finished at least 8.8 hours before bedtime to avoid losing sleep, so for a 23:00 bedtime that means roughly 14:00. Bigger doses need a longer gap: the same analysis put a 217.5 mg pre-workout drink at 13.2 hours. How fast you clear caffeine varies a lot from person to person, so treat this as a starting point, not a rule.
How caffeine keeps you awake
While you are awake, a chemical called adenosine builds up in your brain, and that build-up is part of what makes you feel sleepy. Caffeine works by blocking adenosine’s action. That is why it feels so useful in the morning, and also why it can still be getting in the way at night if there is enough of it left in your body.
Caffeine’s half-life, and why yours may differ
In adults, caffeine’s half-life (the time it takes your body to clear half of it) is about 3–7 hours. That range is wide on purpose: elimination varies a lot between healthy adults, which is one reason published cutoff advice ranges from 4 to 11 hours before bed. Some of the known reasons:
- Genes. A liver enzyme called CYP1A2 handles about 95% of the caffeine you swallow. Common genetic variations in it, and in the adenosine receptor caffeine acts on, are a major source of differences in how fast people break caffeine down and how sensitive they are to it.
- The contraceptive pill. Oral contraceptives slow caffeine clearance. In one study, women on low-dose oestrogen pills had an average half-life of 7.88 hours versus 5.37 hours in similar women not taking them; a review summarises that the pill tends to double the half-life.
- Pregnancy. Caffeine’s half-life is on average 8.3 hours longer during pregnancy and may be as much as 16 hours longer than usual. EFSA considers up to 200 mg a day from all sources safe for the foetus.
- Smoking. Cigarette smoking speeds caffeine elimination, roughly doubling clearance, so smokers have a shorter half-life.
There is no guideline that sets a genotype-specific cutoff, so the practical message is simple: if a mid-afternoon coffee seems to keep you up, you may be on the slow end of the range.
What the studies actually tested
The study most often quoted on this topic is Drake et al. (2013). It is useful, but it is worth knowing what it did. Twelve healthy normal sleepers took 400 mg of caffeine as a pill (roughly what is in two to four cups of coffee) at 0, 3 or 6 hours before their usual bedtime, and slept at home with a portable sleep monitor. At all three times, caffeine disrupted sleep compared with placebo; measured total sleep fell by about 1.1–1.2 hours. Even at 6 hours, caffeine cut sleep by more than an hour.
Two details stand out. At 6 hours, most of the loss went unnoticed: in their sleep diaries, participants reported 41 fewer minutes, a difference that did not reach statistical significance, and only the monitor picked up the full effect. Deep sleep was reduced, while REM was not affected. The study also has clear limits: 12 people, one large dose, and sleep measured with a consumer home monitor rather than in a sleep lab. It shows that a big dose six hours before bed can cost sleep; it does not show that a single afternoon cup does the same.
For a per-cup answer, the better basis is the 2023 meta-analysis of 24 studies. Across them, caffeine reduced total sleep time by 45 minutes and sleep efficiency by 7%, made it take 9 minutes longer to fall asleep, added 12 minutes awake during the night, and reduced deep sleep by 11.4 minutes while increasing light sleep. From that data the authors calculated the 8.8-hour gap for a 107 mg coffee and 13.2 hours for a 217.5 mg pre-workout supplement.
Find your own caffeine cutoff time
Start from your usual bedtime and count back 8.8 hours for a regular cup of coffee. Rounded down to the hour, that gives:
| Usual bedtime | Last regular coffee (about 107 mg) |
|---|---|
| 22:00 | about 13:00 |
| 23:00 | about 14:00 |
| 24:00 (midnight) | about 15:00 |
This is a conservative starting point, not a rule. If your coffee is stronger than 107 mg, if you are pregnant or on the pill, or if you know caffeine hits you hard, give yourself more room. Smokers tend to clear caffeine faster, but the range is still wide. If you are not sure what your bedtime should be, the bedtime calculator by wake-up time can help you pick one first. And if you rely on an afternoon coffee nap, the same cutoff applies to that caffeine too.
How much caffeine is in your drink?
Caffeine content varies by product and portion size, so these are typical figures rather than exact amounts.
| Drink or food | Typical caffeine | Source |
|---|---|---|
| Brewed coffee, 12 fl oz | 113–247 mg | FDA |
| Filter coffee, 200 mL | about 90 mg | EFSA |
| Espresso, 60 mL | about 80 mg | EFSA |
| Black tea, 12 fl oz | 71 mg | FDA |
| Green tea, 12 fl oz | 37 mg | FDA |
| Caffeinated soft drink, 12 fl oz | 23–83 mg | FDA |
| Energy drink, 16 fl oz | 54–328 mg | FDA |
| Plain chocolate, 50 g bar | about 25 mg | EFSA |
| Decaf coffee, 8 fl oz | 2–15 mg | FDA |
Note the last row: decaf is not caffeine-free. It is a small amount, but several cups in the evening still add up. EFSA also notes that a single dose of 100 mg may affect sleep in some adults, particularly close to bedtime.
Daily limits
The FDA cites 400 mg a day, about two to three 12-oz cups of coffee, as an amount not generally linked with negative effects for most adults, while noting that sensitivity varies widely. EFSA says up to 400 mg a day spread over the day, and single doses up to 200 mg, raise no safety concerns for healthy adults other than pregnant women; for pregnancy it considers up to 200 mg a day safe for the foetus. For children and teens EFSA proposes 3 mg per kg of body weight per day, and medical experts advise against energy drinks for them. Staying under the daily limit does not protect your sleep on its own, though: timing matters as much as the total.
Waking up without leaning on caffeine
Moving your last coffee earlier tends to work best alongside a steady wake-up time. MathWake is an iPhone alarm that asks you to solve a short mission before it stops, so you get out of bed instead of snoozing, and it rings even on silent. Its sleep tracker gives a sleep score from your phone’s motion and sound (see how accurate sleep trackers are), and the sleep calculator suggests bedtimes in 90-minute cycles.
Wake up on time, without the extra coffee
MathWake makes you solve a quick mission before the alarm stops, rings even on silent, and tracks your nights with a sleep score.
Download MathWake for iPhoneFrequently asked questions
How many hours before bed should I stop drinking coffee?
A 2023 meta-analysis of 24 studies found a regular coffee (about 107 mg of caffeine) should be finished at least 8.8 hours before bedtime to avoid losing sleep. Stronger drinks need a longer gap.
What is the half-life of caffeine?
About 3–7 hours in adults. It is longer during pregnancy and in people taking the contraceptive pill, and shorter in smokers; genes also play a large part.
Is a coffee at 3 PM too late?
It depends on your bedtime and the dose. Using the 8.8-hour figure, a regular coffee at 15:00 fits a bedtime around midnight; for an earlier bedtime, move it earlier.
Does decaf coffee have caffeine?
Yes, a little. The FDA says decaf typically has 2–15 mg per 8 fl oz cup, so several evening cups add up.
How much caffeine is safe per day?
The FDA and EFSA both cite up to 400 mg a day for most healthy adults, and EFSA advises up to 200 mg a day during pregnancy. A safe daily amount can still disturb sleep if it is taken late.