Caffeine has been shown to disrupt sleep, so understanding how long it stays in your system is key to protecting sleep quality.

Caffeine has a half-life of about five hours. That means half the caffeine of a flat white at 8 am is still in your bloodstream at 1pm.

But caffeine clearance differs so much between people that doctors use it as a liver function test.

In this guide, we explain how long it takes for caffeine to be cleared from your system.

Key takeaways

  • Caffeine’s half-life averages about five hours, so half of an afternoon coffee is still with you at bedtime.
  • Clearance varies enough between people that caffeine is used clinically to test how well a liver is working.
  • Oral contraceptives stretch the half-life from about 5.4 hours to 7.9. Smoking shortens it. Around half of people carry a slow version of the gene involved.
  • In the trial, caffeine taken six hours before bed measurably disrupted sleep.

What caffeine half-life actually means

Half-life is how long your body takes to clear half a dose. Take 200 mg of caffeine (roughly a large coffee) at 8am:

TimeCaffeine still circulating
8am200 mg
2pm100 mg
8pm50 mg
2am25 mg

At 8pm you are carrying about as much caffeine as a small espresso. At 2am there is still a measurable amount in your blood – even if the effects feel long gone.

How much caffeine is OK for sleep?

There’s no magic number. Researchers haven’t found a safe threshold, and how fast you clear caffeine varies hugely from person to person.

A regular coffee needs about nine hours to stop affecting your sleep. So if you’re in bed for 11pm, your last coffee should be by 2pm.

But remember: A double shot needs even longer.

What changes your clearance rate

  • Caffeine is broken down almost entirely by CYP1A2 in the liver, and the gene for it comes in faster and slower versions. In a study of 4,028 people in Costa Rica , around 54% carried the slow variant. If caffeine hits you harder than it hits your friends, this is the most likely reason.
  • Nine women taking low-dose oestrogen-containing contraceptives were compared with nine matched controls . Half-life on the pill was 7.9 hours. Off it, 5.4. That is two and a half hours of difference from the same cup of coffee.
  • Tobacco smoke induces CYP1A2, so smokers clear caffeine considerably faster. It reverses on quitting, which is why coffee can suddenly feel much stronger a week after your last cigarette.
  • Pregnancy slows it substantially, and increasingly so as pregnancy progresses.
  • So does anything affecting your liver. Caffeine is cleared almost entirely there, so liver conditions and drugs competing for the same enzyme both change the rate.

What this means for sleep

The familiar advice is to stop caffeine six hours before bed. That figure comes from a specific trial.

Participants took 400 mg of caffeine , roughly four cups of coffee, either at bedtime, three hours before bed, or six hours before. All three disrupted sleep compared with placebo.

The dose was high, so one small coffee is not the same test. And six hours was the longest gap they tried. Nobody tested eight hours, or ten, which matters if you are on the pill or carry the slow gene.

Caffeine also lengthens the time you take to fall asleep and reduces all-important deep sleep – which is when the body repairs itself.

Finding your own cutoff

The Caffeine Window PowerPlug for Ultrahuman Ring enables you to log caffeinated beverages and sets a cutoff based on your own sleep patterns.

  • Get a personalized caffeine cut-off based on your sleep and the quality of last night’s rest.
  • Log beverages to see the half-life of coffee in your system.
  • Receive advice on early cut-offs or a caffeine detox day, if sleep quality is poor.

Frequently asked questions

How long does it take for caffeine to fully leave your system?

Most of a dose is gone within about 24 hours, with traces lasting longer. The half-life of roughly five hours is the more practical number, because it tells you how much is still working at bedtime.

Does caffeine affect sleep even if I fall asleep fine?

Yes. It cuts deep sleep as well as delaying sleep onset. Falling asleep easily tells you the stimulant effect has faded, not that the caffeine has gone.

Why does caffeine affect some people more than others?

Mostly the CYP1A2 enzyme. Around half of people have a slower version of the gene behind it. Hormonal contraception, smoking, pregnancy and liver function all shift the rate too.

Is decaf caffeine-free?

No. A cup of decaf holds a small fraction of the caffeine in a regular cup. Low enough not to matter for most people in the evening, but not zero.

References

  1. Grzegorzewski J, Bartsch F, Köller A, König M. Pharmacokinetics of caffeine: a systematic analysis of reported data for application in metabolic phenotyping and liver function testing. Frontiers in Pharmacology 2022;12:752826. PMID 35280254 . Pooled analysis of 141 publications.
  2. Drake C, Roehrs T, Shambroom J, Roth T. Caffeine effects on sleep taken 0, 3, or 6 hours before going to bed. Journal of Clinical Sleep Medicine 2013;9(11):1195–1200. PMID 24235903 . 400 mg doses.
  3. Abernethy DR, Todd EL. Impairment of caffeine clearance by chronic use of low-dose oestrogen-containing oral contraceptives. European Journal of Clinical Pharmacology 1985;28(4):425–428. PMID 4029248 . Nine women per group.
  4. Cornelis MC, El-Sohemy A, Kabagambe EK, Campos H. Coffee, CYP1A2 genotype, and risk of myocardial infarction. JAMA 2006;295(10):1135–1141. PMID 16522833 . 2,014 cases and 2,014 controls. Cited here for genotype prevalence only.