# Caffeine Half-Life Calculator

> Computes the caffeine remaining after a given time by first-order elimination with an adjustable half-life (about 5 hours in healthy adults), the time until the amount falls below a threshold, and a 24-hour decay schedule.

- Calculator id: `caffeine-half-life` · Category: Health (`health`) · Tool name: `calculate_caffeine_remaining`
- Canonical page: https://tttkmbb.com/health/caffeine-half-life · This document: https://tttkmbb.com/health/caffeine-half-life.md · JSON definition: https://tttkmbb.com/health/caffeine-half-life.json

## Purpose

Computes the caffeine remaining after a given time by first-order elimination with an adjustable half-life (about 5 hours in healthy adults), the time until the amount falls below a threshold, and a 24-hour decay schedule.

**Use when:** You want to know how much of a coffee, tea or energy-drink dose is still active after some hours, or when it will drop below a chosen level before bedtime.

**Do not use when:** You need guidance for pregnancy, liver disease, children or drug interactions, where the half-life can be two to three times longer; the result is informational only, not medical advice. For generic exponential decay use half-life.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `dose_mg` | number | mg | required | Caffeine taken at time zero. Typical: brewed coffee ≈ 95 mg per 240 mL cup, espresso ≈ 63 mg per 30 mL shot, black tea ≈ 47 mg per cup, cola ≈ 34 mg per 355 mL, energy drink ≈ 80 mg per 250 mL. (> 0, max 2000) |
| `hours_elapsed` | number | h | required | Time since the dose was taken. (min 0, max 72) |
| `half_life_hours` | number | h | optional, default 5 | Elimination half-life: about 5 h in healthy adults (FDA), shorter in smokers (≈ 3 h), longer with oral contraceptives, in pregnancy or with liver disease. (min 1.5, max 10) |
| `threshold_mg` | number | mg | optional, default 25 | Amount below which the remaining caffeine is considered negligible (25 mg ≈ a quarter cup of coffee). (> 0, max 2000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `remaining_mg` | number | mg | Caffeine still in the body after hours_elapsed. |
| `percent_remaining` | number | % | remaining_mg as a percentage of the dose. |
| `half_lives_elapsed` | number |  | hours_elapsed / half_life_hours. |
| `hours_until_threshold` | number | h | Time from the dose until the amount falls to threshold_mg (0 when the dose is already at or below it). |
| `hours_until_threshold_from_now` | number | h | hours_until_threshold minus hours_elapsed, floored at 0. |
| `schedule` | list |  | Objects with hours and remaining_mg at 0, 2, 4, 6, 8, 10, 12, 16, 20 and 24 hours after the dose. |

## Formula

`remaining_mg = dose_mg × 0.5^(hours_elapsed / half_life_hours); percent_remaining = 100 × 0.5^(hours_elapsed / half_life_hours); hours_until_threshold = half_life_hours × log2(dose_mg / threshold_mg), 0 when dose_mg ≤ threshold_mg; hours_until_threshold_from_now = max(0, hours_until_threshold − hours_elapsed)`

Assumes first-order (exponential) elimination and complete absorption at time zero; absorption actually takes 30–60 minutes and the half-life ranges from about 1.5 to 9.5 h between adults. Informational only, not medical advice.

## Data Sources

- FDA – Spilling the Beans: How Much Caffeine is Too Much? — https://www.fda.gov/consumers/consumer-updates/spilling-beans-how-much-caffeine-too-much (government, retrieved 2026-09-24)
- Wikipedia – Caffeine (pharmacokinetics) — https://en.wikipedia.org/wiki/Caffeine (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/caffeine-half-life?dose_mg=…&hours_elapsed=…`
- `POST https://tttkmbb.com/api/v1/calculate/caffeine-half-life` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/caffeine-half-life · OpenAPI operationId `calculate_caffeine_remaining` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "caffeine-half-life", "inputs": {…}}`

## Example

- 200 mg after 10 h, half-life 5 h: inputs `{"dose_mg":200,"hours_elapsed":10,"half_life_hours":5,"threshold_mg":25}` → `{"remaining_mg":50,"percent_remaining":25,"half_lives_elapsed":2,"hours_until_threshold":15,"hours_until_threshold_from_now":5}`
- One 95 mg coffee after 6 h: inputs `{"dose_mg":95,"hours_elapsed":6}` → `{"remaining_mg":41.35,"percent_remaining":43.53,"hours_until_threshold":9.63,"hours_until_threshold_from_now":3.63}`

```
GET https://tttkmbb.com/api/v1/calculate/caffeine-half-life?dose_mg=200&hours_elapsed=10&half_life_hours=5&threshold_mg=25
```

## Limitations

You need guidance for pregnancy, liver disease, children or drug interactions, where the half-life can be two to three times longer; the result is informational only, not medical advice. For generic exponential decay use half-life. Assumes first-order (exponential) elimination and complete absorption at time zero; absorption actually takes 30–60 minutes and the half-life ranges from about 1.5 to 9.5 h between adults. Informational only, not medical advice. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**How much caffeine is in my drink?**

Roughly: brewed coffee 95 mg per 240 mL cup, espresso 63 mg per shot, black tea 47 mg, green tea 28 mg, cola 34 mg per 355 mL can, energy drink 80 mg per 250 mL. Check the label when it states a value.

**When should I stop drinking coffee before bed?**

With a 5 h half-life, half of a dose is still present after 5 h and a quarter after 10 h; many sleep guidelines suggest no caffeine within 6–8 hours of bedtime. Use the threshold outputs to find the time for your own dose.

## Related

- [Half-Life Calculator](https://tttkmbb.com/chemistry/half-life.md) — Generic exponential decay for any substance or half-life.
- [Sleep Cycle Calculator](https://tttkmbb.com/everyday/sleep-cycles.md) — Plan a bedtime once the caffeine has worn off.
