{
  "id": "caffeine",
  "version": "779a4a1ae33a",
  "status": "published",
  "name": "Caffeine Calculator",
  "question": "How much caffeine is in my body?",
  "summary": "Adds up the caffeine you had today against the FDA’s 400 mg a day, and estimates how much is still in your body now and later from a 5-hour half-life.",
  "category": "health",
  "subcategory": "nutrition",
  "url": "https://www.acalculator.org/health/caffeine-calculator",
  "markdown": "https://www.acalculator.org/health/caffeine-calculator.md",
  "kind": "function",
  "method": "Caffeine left = Σ mg × 0.5^((hours ago + hours from now) ÷ half-life); caffeine today = Σ mg, compared with 400 mg.",
  "assumptions": [
    "Each drink counts in full the moment you have it; in reality caffeine is absorbed over about an hour.",
    "Caffeine leaves at a steady half-life, about 5 hours in adults. It is shorter in smokers and much longer in pregnancy and with some medicines.",
    "The FDA’s 400 mg a day is for healthy adults; it is not a target, and some people should have less.",
    "This is an estimate, not medical advice."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "d": {
        "title": "Drinks today",
        "description": "One row per drink: its caffeine in milligrams and how many hours ago you had it.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "mg": {
              "title": "Caffeine (mg)",
              "description": "The caffeine in the drink, in milligrams; 12 fl oz of brewed coffee has 113 to 247 mg (FDA).",
              "type": "number",
              "minimum": 0,
              "maximum": 2000
            },
            "h": {
              "title": "Hours ago",
              "description": "How many hours ago you drank it; 0 for now.",
              "type": "number",
              "minimum": 0,
              "maximum": 24
            }
          }
        }
      },
      "half": {
        "title": "Half-life (hours)",
        "description": "The hours for your body to clear half the caffeine: about 5 for adults (PubChem); longer in pregnancy.",
        "type": "number",
        "minimum": 1,
        "maximum": 30
      },
      "later": {
        "title": "Hours from now",
        "description": "A time to check, for example your bedtime, in hours from now.",
        "type": "number",
        "minimum": 0,
        "maximum": 48
      }
    }
  },
  "outputs": {
    "now": {
      "label": "Caffeine in your body now",
      "description": "What is left of every drink after its hours ago, halving every half-life.",
      "format": "number"
    },
    "total": {
      "label": "Caffeine today",
      "description": "All the caffeine of the drinks added up.",
      "format": "number"
    },
    "share": {
      "label": "Share of 400 mg",
      "description": "Caffeine today as a percent of the FDA’s 400 mg a day for healthy adults.",
      "format": "percent"
    },
    "room": {
      "label": "Left before 400 mg",
      "description": "400 mg minus the caffeine today, or 0 when you are over.",
      "format": "number"
    },
    "limit": {
      "label": "Against the FDA guide",
      "description": "Whether today’s caffeine is under, at or over 400 mg.",
      "format": "text"
    },
    "laterMg": {
      "label": "Caffeine left later",
      "description": "What will be left at the hours from now you chose, with no more drinks.",
      "format": "number"
    },
    "halfLife": {
      "label": "Hours until half of now is gone",
      "description": "One half-life: the time for the caffeine in your body now to halve.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "d": [
        {
          "mg": 150,
          "ago": 6
        },
        {
          "mg": 71,
          "ago": 2
        }
      ],
      "half": 5,
      "later": 8
    },
    "outputs": {
      "now": 119.09923035832844,
      "total": 221,
      "share": 55.3,
      "room": 179,
      "limit": "Under the FDA’s 400 mg a day for healthy adults",
      "laterMg": 39.288094156194404,
      "halfLife": 5
    },
    "text": "Of the 221 mg you had today, about 119 mg is still in your body."
  },
  "examples": [
    {
      "given": {
        "d": [
          {
            "mg": 200,
            "ago": 5
          }
        ],
        "half": 5,
        "later": 5
      },
      "expect": {
        "now": 100,
        "total": 200,
        "share": 50,
        "room": 200,
        "laterMg": 50,
        "limit": "Under the FDA’s 400 mg a day for healthy adults"
      },
      "source": "hand calculation in content.mdx: 200 × 0.5^(5 ÷ 5) = 100 mg; PubChem, Caffeine (CID 2519), Biological Half-Life: about 5 hours in an average adult; shorter in smokers, 15 hours or more in late pregnancy (https://pubchem.ncbi.nlm.nih.gov/compound/Caffeine#section=Biological-Half-Life, retrieved 2026-10-02); FDA, Spilling the Beans: How Much Caffeine is Too Much?: 400 mg a day for healthy adults; caffeine per 12 fl oz of drinks (https://www.fda.gov/consumers/consumer-updates/spilling-beans-how-much-caffeine-too-much, retrieved 2026-10-02)"
    },
    {
      "given": {
        "d": [
          {
            "mg": 150,
            "ago": 6
          },
          {
            "mg": 71,
            "ago": 2
          }
        ],
        "half": 5,
        "later": 8
      },
      "expect": {
        "total": 221,
        "share": 55.3,
        "now": 119.09923035832844,
        "laterMg": 39.288094156194404
      },
      "source": "hand calculation in content.mdx: 150 × 0.5^1.2 + 71 × 0.5^0.4; PubChem, Caffeine (CID 2519), Biological Half-Life: about 5 hours in an average adult; shorter in smokers, 15 hours or more in late pregnancy (https://pubchem.ncbi.nlm.nih.gov/compound/Caffeine#section=Biological-Half-Life, retrieved 2026-10-02); FDA, Spilling the Beans: How Much Caffeine is Too Much?: 400 mg a day for healthy adults; caffeine per 12 fl oz of drinks (https://www.fda.gov/consumers/consumer-updates/spilling-beans-how-much-caffeine-too-much, retrieved 2026-10-02)"
    },
    {
      "given": {
        "d": [
          {
            "mg": 247,
            "ago": 3
          },
          {
            "mg": 246,
            "ago": 1
          }
        ],
        "half": 5,
        "later": 0
      },
      "expect": {
        "total": 493,
        "share": 123.3,
        "room": 0,
        "limit": "Over the FDA’s 400 mg a day for healthy adults"
      },
      "source": "FDA, Spilling the Beans: How Much Caffeine is Too Much?: 400 mg a day for healthy adults; caffeine per 12 fl oz of drinks (https://www.fda.gov/consumers/consumer-updates/spilling-beans-how-much-caffeine-too-much, retrieved 2026-10-02): up to 247 mg in 12 fl oz of brewed coffee and up to 246 mg in an energy drink"
    }
  ],
  "sources": [
    "U.S. Food and Drug Administration, Spilling the Beans: How Much Caffeine is Too Much? (400 mg a day for healthy adults; caffeine per 12 fl oz: soft drinks 23–83 mg, green tea 37 mg, black tea 71 mg, brewed coffee 113–247 mg, energy drinks 41–246 mg), retrieved 2026-10-02. https://www.fda.gov/consumers/consumer-updates/spilling-beans-how-much-caffeine-too-much",
    "National Library of Medicine, PubChem, Caffeine (CID 2519), Biological Half-Life (about 5 hours in an average adult; up to 50% shorter in smokers; 15 hours or more in pregnancy), retrieved 2026-10-02. https://pubchem.ncbi.nlm.nih.gov/compound/Caffeine#section=Biological-Half-Life"
  ],
  "related": [
    "sleep",
    "water-intake",
    "calorie",
    "starbucks-calories"
  ],
  "changelog": []
}
