{
  "schemaVersion": 1,
  "slug": "liters-gallons-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "895e9ceff0fdba0a3b8d8da45fdcd961b82b30728cd2713c4f78ba66daba7b34",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/liters-gallons-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 = gal_US × 3.785411784; gal_US = L ÷ 3.785411784; gal_UK = L ÷ 4.54609",
    "vars": [
      [
        "L",
        "litres"
      ],
      [
        "gal_US",
        "US gallons"
      ],
      [
        "gal_UK",
        "UK (imperial) gallons"
      ],
      [
        "value",
        "entered amount"
      ]
    ],
    "note": "Direction selects US gallons → litres, litres → US gallons, or litres → UK gallons."
  },
  "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": "1 US gallon = 3.785411784 L; 1 imperial gallon = 4.54609 L.",
    "limitations": "US customary and imperial liquid measures differ. This is volume, not ingredient mass; no density conversion is performed.",
    "implementationHash": "895e9ceff0fdba0a3b8d8da45fdcd961b82b30728cd2713c4f78ba66daba7b34",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const F={\"l\":1,\"gal\":3.785411784,\"galuk\":4.54609}, U={\"l\":\"L\",\"gal\":\"US gal\",\"galuk\":\"UK gal\"}, L={\"l2gal\":[\"l\",\"gal\"],\"gal2l\":[\"gal\",\"l\"],\"l2galuk\":[\"l\",\"galuk\"]}; const pair=Object.prototype.hasOwnProperty.call(L,direction)?L[direction]:[from,to], source=pair[0], target=pair[1]; if(!Number.isFinite(value)||value<0||value>1000000000000||!Object.prototype.hasOwnProperty.call(F,source)||!Object.prototype.hasOwnProperty.call(F,target))return {\"result\":null,\"litres\":null,\"gallonsUS\":null,\"gallonsUK\":null,\"__error\":\"inputError\"}; const base=value*F[source], out=(function(value,direction){const litres = direction === 'gal2l' ? value*3.785411784 : value; return { result: direction === 'gal2l' ? litres : direction === 'l2galuk' ? litres/4.54609 : litres/3.785411784, litres, gallonsUS: litres/3.785411784, gallonsUK: litres/4.54609 };})(base/F[\"l\"],\"l2gal\"); if(out.__error)return {...{\"result\":null,\"litres\":null,\"gallonsUS\":null,\"gallonsUK\":null},...out}; out.result=value*(F[source]/F[target]);out.__resultUnit=U[target];out.__unitRatio=F[target]/F[source];return out;",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 50,
        "min": 0,
        "max": 1000000000000,
        "step": 0.01,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "direction",
        "type": "select",
        "default": "auto",
        "options": [
          {
            "value": "auto"
          },
          {
            "value": "l2gal"
          },
          {
            "value": "gal2l"
          },
          {
            "value": "l2galuk"
          }
        ],
        "showWhen": {
          "from": []
        }
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      },
      {
        "name": "from",
        "type": "select",
        "default": "l",
        "options": [
          {
            "value": "l"
          },
          {
            "value": "gal"
          },
          {
            "value": "galuk"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "gal",
        "options": [
          {
            "value": "gal"
          },
          {
            "value": "l"
          },
          {
            "value": "galuk"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "litres",
        "precision": 4,
        "unit": "L",
        "showWhen": {
          "to": [
            "gal",
            "galuk"
          ]
        },
        "notation": "auto"
      },
      {
        "name": "gallonsUS",
        "precision": 4,
        "unit": "gal",
        "notation": "auto",
        "showWhen": {
          "to": [
            "l",
            "galuk"
          ]
        }
      },
      {
        "name": "gallonsUK",
        "precision": 4,
        "unit": "gal",
        "notation": "auto",
        "showWhen": {
          "to": [
            "l",
            "gal"
          ]
        }
      }
    ],
    "interpret": null
  }
}
