Better sleep starts with better timing. Find your ideal bedtime in seconds.
Best Time For BedCalculate My Sleep
Habits & environment

Caffeine and Sleep: How Long Before Bed Should You Stop?

By Nauman, Founder and Editor · Updated October 20, 2026 · 3 min read

Caffeine is the world’s favourite stimulant, and most of us use it without thinking. The trouble is that it lingers longer than we feel it, so an afternoon coffee can quietly erode that night’s sleep. Here is how to enjoy caffeine without paying for it at 2 AM.

Key takeaways

  • Caffeine’s half-life is around five to six hours for many people.
  • Even caffeine taken six hours before bed can reduce sleep.
  • A cutoff time in early afternoon works for most people.

How caffeine blocks sleep

Caffeine blocks adenosine, a chemical that builds up during the day and makes you sleepy. Blocking it makes you feel alert, but the adenosine is still there, which is why you can crash when caffeine wears off. The average half-life is about five to six hours, so half of an afternoon coffee may still be in your system at bedtime. Sensitivity varies a lot between people.

What research found

In a 2013 study published in the Journal of Clinical Sleep Medicine, caffeine taken six hours before bedtime reduced total sleep time by more than an hour compared with placebo, even though participants did not always feel it. That is why many people sleep better when they stop caffeine earlier than they expected.

How much is in your cup?

DrinkApproximate caffeine
Brewed coffee (240 ml)80–100 mg
Espresso (30 ml)60–65 mg
Black tea (240 ml)40–50 mg
Cola (330 ml)30–40 mg
Energy drink (250 ml)70–150 mg

Amounts vary by brand and preparation. Check labels.

Setting a cutoff

A common suggestion is to stop caffeine about eight hours before bed, which means around 2 PM for a 10 PM bedtime. If you are sensitive or struggle with sleep, try noon. Switch afternoon drinks to decaf, herbal tea or water.

Cutting back without headaches

Quitting abruptly can cause headaches and fatigue for a few days. Reduce gradually by a quarter of a cup every few days. If you use coffee to survive a short night, remember that the way out is more sleep; our sleep debt guide helps.

Special cases

Pregnant women are commonly advised to keep caffeine to about 200 mg a day. Children and teenagers should limit caffeine, including energy drinks. People with anxiety or palpitations often feel better with less. See sleep and anxiety.

Frequently asked questions

How long does caffeine stay in your system?

Its half-life averages five to six hours but varies from about three to over seven. Traces can last longer.

Does decaf have caffeine?

Yes, a small amount, usually 2 to 15 mg per cup.

References and further reading: Drake et al., 2013, Journal of Clinical Sleep Medicine (caffeine and sleep six hours before bed); American College of Obstetricians and Gynecologists guidance on caffeine in pregnancy.

About the author

Nauman, founder and editor of Best Time For Bed. He explains published sleep guidance in plain language and cites his sources. He is not a medical professional, and this page has not been medically reviewed. Read our editorial policy and sources, and talk to a doctor about personal health concerns.

Keep reading

Habits & environment

Alcohol and Sleep: Why Feeling Sleepy Isn't Sleeping Well

Learn how alcohol can change sleep quality, nighttime waking, breathing, and the way you feel the next morning.

Read guide →
Habits & environment

How to Set Up a Better Bedroom for Sleep

A practical bedroom setup guide covering light, sound, temperature, bedding, clutter, and nighttime distractions.

Read guide →
Habits & environment

What Is the Best Sleep Position?

Compare side, back, and stomach sleeping positions and learn how to choose a comfortable position for your body.

Read guide →

Ready to find your sleep time?

Plan a bedtime or wake-up time in under a minute with our free sleep calculator.

Open the sleep calculator