For many of us, the day does not really start until the first cup of coffee. Caffeine is the most widely used stimulant in the world, and for good reason: it helps with alertness and focus. But the same properties that make it useful in the morning can quietly work against your sleep at night, sometimes even when you do not feel wired.

This guide explains how caffeine works, how long it stays in your body, what research says about its effect on sleep, and how to enjoy caffeine without sacrificing the deep sleep and REM sleep you need. It is general information, not medical advice.

Steaming mug of coffee on a wooden table in warm light
Photo: Ilman Muhammad / Pexels
Woman sleeping in a cool bedroom with the Good Sleep bed cooling system

Good Sleep cooling and heating mattress topper

A water-based mattress topper that cools to 62°F and heats to 110°F and fits on top of the mattress you already have. Simple touch-panel control with no app, Wi-Fi or subscription. Dual zone on King.

Shop now

How caffeine works

Through the day, a chemical called adenosine builds up in your brain. Adenosine is one of the signals behind sleep pressure, the growing drive to sleep the longer you are awake. Caffeine works mainly by blocking adenosine receptors. It does not remove adenosine; it simply stops your brain from responding to it as strongly for a while.

That is why caffeine can make you feel alert even when you are tired. It is also why the tiredness can come back quickly when the caffeine wears off, because the adenosine was there all along.

How long caffeine lasts

Caffeine’s half-life, the time it takes your body to clear half of it, is often estimated at around five hours in healthy adults, but it varies widely from person to person, roughly from two to ten hours or more. Genetics, pregnancy, some medications, liver function and smoking can all change how quickly you clear it.

In practical terms, if you drink a large coffee mid-afternoon, a meaningful amount of that caffeine may still be in your system at bedtime.

What caffeine does to sleep

Research on caffeine and sleep has consistently found that caffeine taken later in the day can:

  • Make it take longer to fall asleep
  • Reduce total sleep time
  • Reduce deep, slow-wave sleep
  • Make sleep lighter and more easily disrupted

One frequently cited study found that a moderate dose of caffeine taken six hours before bed still reduced total sleep time, even though participants did not always notice it themselves. That is one reason many sleep experts suggest a cutoff well before bedtime.

Does caffeine reduce REM sleep?

The effect of caffeine on REM sleep specifically is less consistent in research than its effect on falling asleep and deep sleep. Some studies have found modest changes in REM, while others have not found large effects. However, anything that shortens your total sleep or delays your bedtime while you still wake at the same time will tend to cut into REM, because REM periods are concentrated toward the end of the night.

So even if caffeine does not target REM directly, late caffeine can still cost you REM by shortening the night and making sleep more broken. Read more about the stage pattern in deep sleep vs REM sleep.

How much caffeine is in common drinks?

Caffeine content varies a lot by brand, brewing method and serving size, so treat these as rough estimates:

Drink Approximate caffeine
Brewed coffee, 8 oz about 80 to 100 mg
Espresso, single shot about 60 to 75 mg
Black tea, 8 oz about 40 to 50 mg
Green tea, 8 oz about 25 to 35 mg
Cola, 12 oz about 30 to 40 mg
Energy drink, 8 to 16 oz about 80 to 300 mg
Dark chocolate, 1 oz about 10 to 25 mg
Decaf coffee, 8 oz about 2 to 15 mg

The U.S. Food and Drug Administration has noted that up to about 400 mg per day is generally not associated with negative effects in most healthy adults, but that is a general figure and not a recommendation. Sensitivity varies, and people who are pregnant, have certain heart conditions or take certain medications may need much less. Ask your doctor what is right for you.

Hidden sources of caffeine

Caffeine can show up in places you might not expect:

  • Pre-workout powders and some protein drinks
  • Some pain relievers and cold medicines
  • Iced teas, sodas and some flavored waters
  • Chocolate desserts and coffee-flavored ice cream
  • “Energy” gummies and supplements

If you have trouble sleeping and cannot figure out why, check labels for an afternoon or evening source.

Finding your caffeine cutoff

There is no single cutoff that suits everyone. A common, practical starting point is to stop caffeine at least eight hours before bed. If you go to bed at 10:30 p.m., that means a cutoff around 2:30 p.m.

If you are sensitive or still struggling to sleep, try moving the cutoff earlier, to late morning or noon, for two weeks and see if anything changes. Keep notes on how quickly you fall asleep and how rested you feel. A simple sleep diary can be more informative than a wearable for this kind of experiment. See sleep trackers and REM sleep for why.

The caffeine-sleep cycle

A common pattern looks like this: poor sleep leads to more caffeine the next day, which leads to worse sleep that night, which leads to even more caffeine. Breaking the loop usually means improving sleep and managing caffeine at the same time.

Practical steps:

  1. Delay your first cup by 30 to 60 minutes after waking and get daylight first. Some people find this smooths their energy through the morning.
  2. Front-load caffeine to the morning.
  3. Switch afternoon drinks to decaf or caffeine-free herbal tea.
  4. Protect a full sleep window so you need less caffeine the next day. See how much REM sleep you need.

Cutting back without the headache

If you regularly have a lot of caffeine, stopping suddenly can cause withdrawal symptoms such as headaches, tiredness, low mood and trouble concentrating, often for a few days. Cutting back gradually usually helps:

  • Reduce by about one cup or one serving every few days.
  • Mix regular and decaf coffee for a while.
  • Stay hydrated and keep meals regular.
  • Expect a few days of lower energy and plan lighter days if you can.

Caffeine, alcohol and the evening

Some people use caffeine to stay alert in the afternoon and then use alcohol to unwind in the evening. That combination can be particularly hard on sleep: caffeine can delay sleep, and alcohol suppresses REM sleep and fragments the second half of the night.

How alcohol affects REM sleep

Alcohol can make it easier to fall asleep and often increases deep sleep early in the night, which is why a night after drinking can feel deep at first. At the same time, it tends to suppress REM sleep in the first half of the night. As your body clears the alcohol over the next few hours, sleep usually becomes lighter and more broken, and some people notice a burst of vivid dreams toward morning as REM rebounds.

The effect generally grows with the amount you drink, and drinks close to bedtime matter most. If you are not aiming to cut alcohol out, finishing your last drink several hours before bed and drinking water alongside it gives your body more time to process it before sleep. The grogginess many people feel the morning after drinking, even after a full night in bed, fits this pattern of lost REM and broken later sleep.

What about naps and caffeine?

Some people use a “coffee nap,” drinking coffee and then taking a 15 to 20 minute nap so that the caffeine kicks in as they wake. This may help daytime alertness for some people, but it is best done early in the afternoon so it does not interfere with nighttime sleep.

Other ways to boost daytime energy

If you are relying on caffeine to get through the day, the underlying issue may be not enough sleep. Alongside a sensible caffeine habit, try:

  • Getting outdoor light in the morning
  • A short walk after lunch
  • Staying hydrated
  • Eating regular meals with protein and fiber
  • Keeping a consistent sleep schedule
  • Making your bedroom cooler, darker and quieter. See sleep environment

When to talk to a doctor

If you feel you need large amounts of caffeine just to function, or you are very sleepy during the day despite spending enough time in bed, talk to a doctor. Persistent daytime sleepiness can be a sign of sleep disorders such as sleep apnea that need proper diagnosis.

A two-week caffeine experiment

If you are not sure whether caffeine is affecting your sleep, a simple personal experiment can help you find out:

  1. Week one: Keep your usual caffeine habit, but write down the time and size of every caffeinated drink, your bedtime, roughly how long it took to fall asleep, how many times you woke and how rested you felt in the morning on a scale of 1 to 5.
  2. Week two: Keep everything else the same, but move your last caffeine to before noon and switch afternoon drinks to decaf or herbal tea.
  3. Compare. Look at the averages rather than any single night. Did you fall asleep faster? Wake less? Feel more rested?

If you notice a clear difference, you have found a useful lever. If you do not, caffeine may not be your main sleep issue, and it is worth looking at other factors like your schedule, stress or bedroom environment.

A cool, comfortable bed helps you stay asleep through the second half of the night. A cooling mattress topper is another option if you have tried the basics and still wake up warm.

Frequently asked questions

How many hours before bed should I stop caffeine?

A practical starting point is at least eight hours before bedtime. Sensitive people may need an earlier cutoff, such as noon.

Does caffeine reduce REM sleep?

Caffeine more consistently affects how quickly you fall asleep, total sleep time and deep sleep. Its direct effect on REM is less clear, but shorter or more broken sleep usually means less REM.

Is decaf okay in the evening?

Decaf still contains a small amount of caffeine, typically a few milligrams per cup. Most people can drink it in the evening without trouble, but very sensitive people may notice an effect.

Does tea affect sleep the same way as coffee?

Black and green tea contain caffeine, usually less than coffee per cup. Herbal teas like chamomile or rooibos are typically caffeine-free.

Why can I drink coffee and still fall asleep?

Some people clear caffeine faster or are less sensitive. Even so, research suggests caffeine can reduce sleep quality and deep sleep without you noticing.

Can caffeine cause insomnia?

Caffeine can contribute to trouble falling and staying asleep, especially in large amounts or late in the day. If insomnia persists after adjusting caffeine, talk to a doctor.

Affiliate Disclosure: This article may contain affiliate links. We may earn a commission on purchases made through our links at no extra cost to you. Affiliate relationships do not influence our editorial assessments. Read our full disclosure policy.

🔬

Get More REM Sleep Editorial Team

Independent researchers covering the science of sleep quality. All content is reviewed against peer-reviewed research and updated quarterly.