{
  "schemaVersion": 1,
  "slug": "cooking-oz-grams-calculator",
  "category": "conversion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "10fcf8d7ab82aedc9909a7d401db719fe7adc90820d129750668c1b385dbb997",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cooking-oz-grams-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": "g = oz × 28.349523125; oz = g ÷ 28.349523125",
    "vars": [
      [
        "oz",
        "ounces (avoirdupois)"
      ],
      [
        "g",
        "grams"
      ]
    ],
    "note": "Converts avoirdupois mass ounces to grams (1 oz = 28.349523125 g), not fluid ounces; volume-to-mass conversion requires ingredient density."
  },
  "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 avoirdupois ounce = 28.349523125 g.",
    "limitations": "Only the displayed unit definitions are converted; rounding and measurement uncertainty are separate.",
    "implementationHash": "10fcf8d7ab82aedc9909a7d401db719fe7adc90820d129750668c1b385dbb997",
    "domain": "conversion"
  },
  "contract": {
    "compute": "const F={\"oz\":28.349523125,\"g\":1}, U={\"oz\":\"oz\",\"g\":\"g\"}, L={\"oz2g\":[\"oz\",\"g\"],\"g2oz\":[\"g\",\"oz\"]}; 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>1000000000||!Object.prototype.hasOwnProperty.call(F,source)||!Object.prototype.hasOwnProperty.call(F,target))return {\"result\":null,\"kg\":null,\"pounds\":null,\"__error\":\"inputError\"}; const base=value*F[source], out=(function(value,direction){const grams = direction === 'oz2g' ? value*28.349523125 : value; return { result: direction === 'oz2g' ? grams : grams/28.349523125, kg: grams/1000, pounds: grams/453.59237 };})(base/F[\"oz\"],\"oz2g\"); if(out.__error)return {...{\"result\":null,\"kg\":null,\"pounds\":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": 8,
        "min": 0,
        "max": 1000000000,
        "step": 0.01,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "direction",
        "type": "select",
        "default": "auto",
        "options": [
          {
            "value": "auto"
          },
          {
            "value": "oz2g"
          },
          {
            "value": "g2oz"
          }
        ],
        "showWhen": {
          "from": []
        }
      },
      {
        "name": "precision",
        "type": "select",
        "default": 4,
        "options": [
          {
            "value": 0
          },
          {
            "value": 2
          },
          {
            "value": 4
          },
          {
            "value": 6
          }
        ]
      },
      {
        "name": "from",
        "type": "select",
        "default": "oz",
        "options": [
          {
            "value": "oz"
          },
          {
            "value": "g"
          }
        ]
      },
      {
        "name": "to",
        "type": "select",
        "default": "g",
        "options": [
          {
            "value": "g"
          },
          {
            "value": "oz"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 4,
        "unit": "",
        "precisionField": "precision",
        "unitField": "__resultUnit",
        "trimTrailingZeros": true,
        "notation": "auto"
      },
      {
        "name": "kg",
        "precision": 4,
        "unit": "kg",
        "notation": "auto"
      },
      {
        "name": "pounds",
        "precision": 4,
        "unit": "lb",
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
