Reviewed by Sahil Chopra, MD.

Research by Savit Malhotra

Introduction

For many people, caffeine is part of the morning routine before the day has even properly begun. Coffee helps us feel more alert, tea gets us through the afternoon, and energy drinks or pre-workout supplements can provide an extra boost when energy starts to fade. But caffeine does not disappear when the cup is empty. Because it can remain in the body for hours, what you drink during the day may still influence your brain long after you get into bed.

Research consistently shows that caffeine can make it harder to fall asleep, shorten total sleep time, reduce sleep efficiency, and alter the amount of deep sleep we get.[1,2] The effect, however, depends heavily on how much caffeine you consume, when you consume it, and how quickly your body processes it.[3,4] That means there is no single caffeine cutoff that works perfectly for everyone.

How Does Caffeine Keep You Awake? 

Caffeine does not actually create energy. Instead, one of its main actions is blocking the effects of adenosine, a chemical involved in building sleep pressure throughout the day. Adenosine gradually accumulates while we are awake and helps increase the drive to sleep. Caffeine binds to adenosine receptors, particularly A1 and A2A receptors, without activating them, temporarily reducing our perception of that growing sleep pressure.[5,6]

That is why caffeine can make you feel more alert even when you are genuinely sleep deprived. The underlying need for sleep has not disappeared; one of the signals telling the brain that it is tired has simply been partially blocked. Caffeine may also influence circadian timing. In one controlled experiment, caffeine equivalent to roughly a double espresso consumed three hours before habitual bedtime delayed the body's melatonin rhythm by approximately 40 minutes.[7] So caffeine can potentially affect both how sleepy you feel and when your biological clock expects sleep.

The other important piece is how long caffeine remains in the body. Its average half-life in healthy adults is around five hours, although estimates can range from roughly 1.5 to 9.5 hours depending on the individual.[8,9] A half-life of five hours means that if someone consumes 200 mg of caffeine at 2 p.m., roughly 100 mg could still remain around 7 p.m. and about 50 mg around midnight. That is only a simplified example, actual metabolism varies considerably, but it illustrates why an afternoon coffee may still matter at bedtime.

What Does Caffeine Actually Do to Sleep?

A 2023 systematic review and meta-analysis examined 24 studies on caffeine and nighttime sleep. On average, caffeine reduced total sleep time by approximately 45 minutes, decreased sleep efficiency by about 7%, increased the time required to fall asleep by around nine minutes, and increased time awake after initially falling asleep by about 12 minutes. Caffeine was also associated with more light sleep and approximately 11 fewer minutes of deep sleep.[1]

A newer 2025 meta-analysis of 22 controlled crossover trials involving 956 participants found a similar pattern. Caffeine reduced total sleep time by about 35 minutes, reduced sleep efficiency, increased sleep-onset latency, and decreased the proportion of slow-wave sleep. The effects on REM sleep were not significant overall.[2] These averages do not mean every cup of coffee costs exactly 35–45 minutes of sleep. The studies used different doses, timing, participants, and methods. Still, the overall direction of the evidence is remarkably consistent: caffeine can affect both how long you sleep and how deeply you sleep.

Importantly, you may not always notice the effect. In a recent randomized trial, participants sometimes showed objective changes in sleep even when they did not report feeling that their sleep had changed as much.[4] Someone may therefore say, “Coffee never affects my sleep because I can fall asleep right after drinking it,” while still experiencing subtle changes in sleep timing, fragmentation, or architecture.

How Late Is Too Late for Caffeine?

This is where the answer becomes more complicated than the familiar advice to “stop drinking coffee after 2 p.m.”

A widely cited 2013 study gave participants 400 mg of caffeine either immediately before bed, three hours before bed, or six hours before bed. Caffeine significantly disrupted sleep at all three time points, including when it was consumed six hours before bedtime.[3] That finding helped support the recommendation that substantial caffeine intake should be avoided for at least several hours before sleep.

But dose matters enormously. A more recent randomized crossover trial compared 100 mg and 400 mg of caffeine consumed 4, 8, or 12 hours before bedtime. The researchers did not find a significant sleep effect from the 100 mg dose even when it was taken four hours before bed. In contrast, 400 mg affected sleep when consumed as far as 12 hours before bedtime, with greater sleep fragmentation when it was consumed within eight hours of sleep.[4]

A 2023 meta-analysis attempted to translate the existing research into practical timing recommendations and estimated that a serving containing approximately 107 mg of caffeine would need to be consumed about 8.8 hours before bed to avoid measurable reductions in total sleep time, while larger doses would require considerably longer.[1] These estimates should not be treated as rigid universal rules. Individual metabolism, habitual intake, sensitivity, and the size of the dose can all change the answer.

A more useful principle is:

The larger the dose, the earlier it should probably be consumed.

Why Can Some People Drink Coffee at Night?

You probably know someone who claims they can drink an espresso after dinner and immediately fall asleep.

They may not be imagining it.

Caffeine metabolism varies substantially between individuals. Much of caffeine is metabolized by an enzyme called CYP1A2, and both genetic and non-genetic factors can influence how quickly that process occurs.[8,9,10] Smoking, pregnancy, hormonal contraceptives, medications, liver function, and genetic variation can all alter caffeine clearance.[8,9] Genetic differences involving the adenosine A2A receptor have also been associated with how strongly caffeine affects sleep and anxiety.[10,11]

Habitual use adds another layer. People who regularly consume caffeine can develop some tolerance to certain effects. However, tolerance does not necessarily mean caffeine has stopped affecting sleep altogether. Studies of repeated caffeine use suggest that the brain adapts to regular exposure, but objective sleep and sleep-pressure responses can still be altered.[5,12]

This also creates a potential cycle. Someone sleeps poorly, feels tired the next morning, consumes more caffeine to compensate, and then carries enough caffeine into the evening to make the next night's sleep less restorative. The following morning, the solution seems obvious: more caffeine. Caffeine can be extremely useful for alertness, but it cannot fully substitute for the biological functions of adequate sleep.

Your Coffee May Contain More Caffeine Than You Think

Another challenge is that “one coffee” is not a standardized dose.

According to the FDA, a typical 12-ounce brewed coffee can contain roughly 113–247 mg of caffeine, while a 12-ounce energy drink may contain approximately 41–246 mg. Black tea, green tea, caffeinated soda, chocolate, certain medications, pre-workout supplements, and other products can add additional caffeine throughout the day.[13]

This means someone who drinks a large coffee in the morning, another coffee after lunch, and a pre-workout before an evening gym session could consume several hundred milligrams without necessarily realizing it. For most healthy adults, the FDA cites 400 mg per day as an amount not generally associated with negative health effects.[13] But that is a general safety guideline, not a guarantee that 400 mg will have no effect on sleep. The timing and size of individual doses still matter.

Pregnancy is one example where recommendations differ. Caffeine metabolism slows during pregnancy, and the American College of Obstetricians and Gynecologists recommends keeping intake below 200 mg per day.[9,14] People taking certain medications or managing particular health conditions may also metabolize caffeine differently and should follow individualized medical advice.

How Can You Use Caffeine Without Sacrificing Sleep?

For most people, quitting caffeine entirely is unnecessary. Instead, the goal is to use it strategically.

Start by looking at timing and dose together. Morning caffeine is much less likely to affect nighttime sleep than the same dose consumed late in the afternoon or evening. If you notice difficulty falling asleep, nighttime awakenings, or feeling unrefreshed despite spending enough time in bed, moving your last caffeinated drink earlier may be an easy experiment.

Pay attention to the actual caffeine content rather than just the number of drinks. A small tea and a large cold brew may both count as “one caffeinated beverage,” but they can contain dramatically different doses.[13] Energy drinks, pre-workout powders, and supplements deserve particular attention because a single serving can contain enough caffeine to remain relevant many hours later.

If you regularly consume large amounts of caffeine, suddenly stopping can produce headache, fatigue, sleepiness, irritability, difficulty concentrating, and reduced alertness.[15,16] Gradually reducing intake may therefore be more comfortable than abruptly eliminating it. Interestingly, simply giving up caffeine does not guarantee dramatic improvements in sleep for every habitual user; one study of young adults with poor sleep found no major long-term improvement in objective sleep measures during a week of caffeine abstinence.[17] Sleep problems often have multiple causes.

Perhaps the most useful approach is to treat caffeine as a tool rather than a replacement for sleep. Use it when alertness is useful, keep larger doses earlier in the day, and pay attention to whether your afternoon caffeine habit is solving today's tiredness at the expense of tomorrow's.

Conclusion

Caffeine works remarkably well at what most people use it for: helping us feel awake. But that same ability can become a problem when its effects extend into the night.

Research consistently shows that caffeine can delay sleep onset, shorten sleep duration, reduce sleep efficiency, and decrease deep sleep.[1,2] The effect becomes more likely as doses increase and move closer to bedtime, but individual metabolism means there is no perfect cutoff time that applies to everyone.[3,4,8]

You do not necessarily need to give up your morning coffee. Instead, consider how much caffeine you are consuming, when you are consuming it, and how well you are actually sleeping.

If you consistently need caffeine to make up for inadequate sleep, the more important question may not be which coffee to order.

It may be why you are so tired in the first place.

‍