{
  "schemaVersion": 1,
  "slug": "volume-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "31f5ed031f023b5102fca0aac1bdc1923cf466e52c47b4a04c91731ba3119c05",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/volume-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": "L = x×F[from]÷F[to]",
    "vars": [
      [
        "x",
        "Value"
      ],
      [
        "from",
        "Source unit"
      ],
      [
        "to",
        "Target unit"
      ],
      [
        "F",
        "Factor to litres"
      ],
      [
        "L",
        "Result (L)"
      ]
    ],
    "note": "F to litres: ml 0.001, l 1, m³ 1000, cm³ 0.001, cup 0.2365882365, pt 0.473176473, qt 0.946352946, US gal 3.785411784, UK gal 4.54609, fl oz 0.0295735295625."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-04",
    "sources": [
      {
        "name": "NIST SP 811 — Conversion factors by quantity",
        "url": "https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b9"
      }
    ],
    "basis": "Convert liquid volume via litres; US and imperial gallons are distinct options.",
    "limitations": "US customary and imperial liquid measures differ. This is volume, not ingredient mass; no density conversion is performed.",
    "implementationHash": "31f5ed031f023b5102fca0aac1bdc1923cf466e52c47b4a04c91731ba3119c05",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const units={\"ml\":\"mL\",\"l\":\"L\",\"m3\":\"m³\",\"cm3\":\"cm³\",\"cup\":\"US cup\",\"pt\":\"US pt\",\"qt\":\"US qt\",\"gal\":\"US gal\",\"galuk\":\"UK gal\",\"floz\":\"US fl oz\"}, factors={\"ml\":0.001,\"l\":1,\"m3\":1000,\"cm3\":0.001,\"cup\":0.2365882365,\"pt\":0.473176473,\"qt\":0.946352946,\"gal\":3.785411784,\"galuk\":4.54609,\"floz\":0.0295735295625}; if(!Number.isFinite(value)||value<-1000000000000||value>1000000000000||!Object.prototype.hasOwnProperty.call(units,from)||!Object.prototype.hasOwnProperty.call(units,to))return {\"result\":null,\"litres\":null,\"gallonsUS\":null,\"__error\":\"inputError\"}; const out=(function(){const F={ml:0.001,l:1,m3:1000,cm3:0.001,cup:0.2365882365,pt:0.473176473,qt:0.946352946,gal:3.785411784,galuk:4.54609,floz:0.0295735295625}; const litres=value*F[from]; return { result: litres/F[to], litres, gallonsUS: litres/3.785411784 };})(); if(out.__error)return {...{\"result\":null,\"litres\":null,\"gallonsUS\":null},...out}; out.__resultUnit=units[to]; out.__unitRatio=factors[to]/factors[from]; return out;",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 1,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 0.01,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "from",
        "type": "select",
        "default": "l",
        "options": [
          {
            "value": "l"
          },
          {
            "value": "ml"
          },
          {
            "value": "m3"
          },
          {
            "value": "cm3"
          },
          {
            "value": "cup"
          },
          {
            "value": "pt"
          },
          {
            "value": "qt"
          },
          {
            "value": "gal"
          },
          {
            "value": "galuk"
          },
          {
            "value": "floz"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "gal",
        "options": [
          {
            "value": "gal"
          },
          {
            "value": "ml"
          },
          {
            "value": "l"
          },
          {
            "value": "m3"
          },
          {
            "value": "cm3"
          },
          {
            "value": "cup"
          },
          {
            "value": "pt"
          },
          {
            "value": "qt"
          },
          {
            "value": "galuk"
          },
          {
            "value": "floz"
          }
        ]
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "litres",
        "precision": 6,
        "unit": "L",
        "showWhen": {
          "to": [
            "ml",
            "m3",
            "cm3",
            "cup",
            "pt",
            "qt",
            "gal",
            "galuk",
            "floz"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "gallonsUS",
        "precision": 6,
        "unit": "gal",
        "notation": "auto",
        "showWhen": {
          "to": [
            "ml",
            "l",
            "m3",
            "cm3",
            "cup",
            "pt",
            "qt",
            "galuk",
            "floz"
          ]
        }
      }
    ],
    "interpret": null
  }
}
