{
  "schemaVersion": 1,
  "slug": "macro-calculator",
  "category": "health",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "c7da9919f99ee63ddf9d760af869009812536c78f6974b43e1cf1b9a03b820f7",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/macro-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "P = kcal × p% ÷ (100 × 4); C = kcal × c% ÷ (100 × 4); F = kcal × f% ÷ (100 × 9)",
    "vars": [
      [
        "P",
        "protein, g/day"
      ],
      [
        "C",
        "carbs, g/day"
      ],
      [
        "F",
        "fat, g/day"
      ],
      [
        "kcal",
        "daily calories"
      ],
      [
        "p%, c%, f%",
        "percent shares of protein, carbs, fat"
      ]
    ],
    "note": "Each macro percentage is calculated independently; the percentages should total 100% for the gram targets to match the calorie target."
  },
  "externalEvidence": {
    "reviewedAt": "2026-09-28",
    "sources": [
      {
        "name": "NIH Office of Dietary Supplements — Dietary Reference Intakes",
        "url": "https://ods.od.nih.gov/HealthInformation/nutrientrecommendations/"
      },
      {
        "name": "USDA Food and Nutrition Information Center — Calories per gram of macronutrients",
        "url": "https://www.nal.usda.gov/programs/fnic"
      }
    ]
  },
  "contract": {
    "compute": "const pC = calories*proteinPct/100, cC = calories*carbsPct/100, fC = calories*fatPct/100; return { protein: pC/4, carbs: cC/4, fat: fC/9, proteinCalories: pC, fatCalories: fC, splitTotalPercent: proteinPct+carbsPct+fatPct };",
    "inputs": [
      {
        "name": "calories",
        "type": "number",
        "default": 2200,
        "min": 500,
        "max": 10000,
        "step": 50,
        "slider": true
      },
      {
        "name": "proteinPct",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "carbsPct",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "fatPct",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "protein",
        "precision": 0,
        "unit": "g/day"
      },
      {
        "name": "carbs",
        "precision": 0,
        "unit": "g/day"
      },
      {
        "name": "fat",
        "precision": 0,
        "unit": "g/day"
      },
      {
        "name": "proteinCalories",
        "precision": 0,
        "unit": "kcal"
      },
      {
        "name": "fatCalories",
        "precision": 0,
        "unit": "kcal"
      },
      {
        "name": "splitTotalPercent",
        "precision": 0,
        "unit": "%"
      }
    ],
    "interpret": null
  }
}
