{
  "id": "unit-converter",
  "version": "31ed7e204ead",
  "status": "published",
  "name": "Unit Converter",
  "question": "How do I convert a measurement?",
  "summary": "Converts a measurement of length, weight, volume, temperature, area, or speed from any unit to any other.",
  "category": "convert",
  "subcategory": "units",
  "url": "https://www.acalculator.org/convert/unit",
  "markdown": "https://www.acalculator.org/convert/unit.md",
  "kind": "function",
  "method": "converted = amount × (base units per \"From\" unit) ÷ (base units per \"To\" unit); temperatures add an offset",
  "assumptions": [
    "Every factor is the exact definition in NIST SP 811 (2008), Appendix B.8: 1 in = 2.54 cm, 1 lb = 0.45359237 kg, 1 US gallon = 231 in³.",
    "Cups, pints, quarts, gallons, and fluid ounces are US customary units.",
    "Temperatures convert through kelvins: K = °C + 273.15 = (°F + 459.67) × 5 ÷ 9. Nothing is colder than 0 K.",
    "A length, weight, volume, area, or speed cannot be negative.",
    "The answer shows at most 6 decimal places; the calculation keeps full precision."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "measure": {
        "title": "Measure",
        "description": "What kind of measurement to convert.",
        "type": "string",
        "enum": [
          "length",
          "weight",
          "volume",
          "temperature",
          "area",
          "speed"
        ]
      },
      "amount": {
        "title": "Amount",
        "description": "The measurement to convert, in the \"From\" unit.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "lengthFrom": {
        "title": "From",
        "description": "The unit of length the amount is in.",
        "type": "string",
        "enum": [
          "mm",
          "cm",
          "m",
          "km",
          "um",
          "nm",
          "in",
          "ft",
          "yd",
          "mi",
          "nmi",
          "mil"
        ]
      },
      "lengthTo": {
        "title": "To",
        "description": "The unit of length to convert to.",
        "type": "string",
        "enum": [
          "mm",
          "cm",
          "m",
          "km",
          "um",
          "nm",
          "in",
          "ft",
          "yd",
          "mi",
          "nmi",
          "mil"
        ]
      },
      "weightFrom": {
        "title": "From",
        "description": "The unit of weight the amount is in.",
        "type": "string",
        "enum": [
          "ug",
          "mg",
          "g",
          "kg",
          "t",
          "gr",
          "oz",
          "lb",
          "ton"
        ]
      },
      "weightTo": {
        "title": "To",
        "description": "The unit of weight to convert to.",
        "type": "string",
        "enum": [
          "ug",
          "mg",
          "g",
          "kg",
          "t",
          "gr",
          "oz",
          "lb",
          "ton"
        ]
      },
      "volumeFrom": {
        "title": "From",
        "description": "The unit of volume the amount is in.",
        "type": "string",
        "enum": [
          "mL",
          "L",
          "cm3",
          "m3",
          "tsp",
          "tbsp",
          "floz",
          "cup",
          "pt",
          "qt",
          "gal",
          "in3",
          "ft3",
          "yd3"
        ]
      },
      "volumeTo": {
        "title": "To",
        "description": "The unit of volume to convert to.",
        "type": "string",
        "enum": [
          "mL",
          "L",
          "cm3",
          "m3",
          "tsp",
          "tbsp",
          "floz",
          "cup",
          "pt",
          "qt",
          "gal",
          "in3",
          "ft3",
          "yd3"
        ]
      },
      "temperatureFrom": {
        "title": "From",
        "description": "The unit of temperature the amount is in.",
        "type": "string",
        "enum": [
          "K",
          "C",
          "F"
        ]
      },
      "temperatureTo": {
        "title": "To",
        "description": "The unit of temperature to convert to.",
        "type": "string",
        "enum": [
          "K",
          "C",
          "F"
        ]
      },
      "areaFrom": {
        "title": "From",
        "description": "The unit of area the amount is in.",
        "type": "string",
        "enum": [
          "mm2",
          "cm2",
          "m2",
          "ha",
          "km2",
          "in2",
          "ft2",
          "yd2",
          "acre",
          "mi2"
        ]
      },
      "areaTo": {
        "title": "To",
        "description": "The unit of area to convert to.",
        "type": "string",
        "enum": [
          "mm2",
          "cm2",
          "m2",
          "ha",
          "km2",
          "in2",
          "ft2",
          "yd2",
          "acre",
          "mi2"
        ]
      },
      "speedFrom": {
        "title": "From",
        "description": "The unit of speed the amount is in.",
        "type": "string",
        "enum": [
          "mps",
          "kmh",
          "mph",
          "fps",
          "kn"
        ]
      },
      "speedTo": {
        "title": "To",
        "description": "The unit of speed to convert to.",
        "type": "string",
        "enum": [
          "mps",
          "kmh",
          "mph",
          "fps",
          "kn"
        ]
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Converted amount",
      "description": "The amount in the \"To\" unit.",
      "format": "number"
    },
    "given": {
      "label": "From",
      "description": "The amount and its unit, as entered.",
      "format": "text"
    },
    "into": {
      "label": "To",
      "description": "The unit the amount is converted to.",
      "format": "text"
    },
    "formula": {
      "label": "Formula",
      "description": "How to convert from the one unit to the other.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "measure": "length",
      "lengthFrom": "in",
      "lengthTo": "cm",
      "weightFrom": "lb",
      "weightTo": "kg",
      "volumeFrom": "gal",
      "volumeTo": "L",
      "temperatureFrom": "F",
      "temperatureTo": "C",
      "areaFrom": "ft2",
      "areaTo": "m2",
      "speedFrom": "mph",
      "speedTo": "kmh",
      "amount": 1
    },
    "outputs": {
      "result": 2.54,
      "given": "1 in",
      "into": "centimeters (cm)",
      "formula": "cm = in × 2.54"
    },
    "text": "1 in = 2.54 centimeters (cm)."
  },
  "examples": [
    {
      "given": {
        "measure": "length",
        "amount": 1,
        "lengthFrom": "in",
        "lengthTo": "cm"
      },
      "expect": {
        "result": 2.54,
        "formula": "cm = in × 2.54"
      },
      "source": "NIST SP 811 (2008) B.8: 1 in = 2.54 cm exactly (content.mdx)"
    },
    {
      "given": {
        "measure": "weight",
        "amount": 150,
        "weightFrom": "lb",
        "weightTo": "kg"
      },
      "expect": {
        "result": 68.0388555
      },
      "source": "NIST SP 811 (2008) B.8: 1 lb = 0.45359237 kg exactly (content.mdx)"
    },
    {
      "given": {
        "measure": "volume",
        "amount": 1,
        "volumeFrom": "gal",
        "volumeTo": "L"
      },
      "expect": {
        "result": 3.785411784
      },
      "source": "NIST SP 811 (2008) B.8: 1 US gallon = 231 in³ = 3.785411784 L (content.mdx)"
    },
    {
      "given": {
        "measure": "temperature",
        "amount": 98.6,
        "temperatureFrom": "F",
        "temperatureTo": "C"
      },
      "expect": {
        "result": 37,
        "formula": "°C = (°F − 32) × 5 ÷ 9"
      },
      "source": "NIST SP 811 (2008) 4.2.1.1: t/°C = (t/°F − 32) ÷ 1.8 (content.mdx)"
    },
    {
      "given": {
        "measure": "area",
        "amount": 1,
        "areaFrom": "acre",
        "areaTo": "ft2"
      },
      "expect": {
        "result": 43560
      },
      "source": "NIST SP 811 (2008) B.8: 1 acre = 43,560 ft² (content.mdx)"
    },
    {
      "given": {
        "measure": "speed",
        "amount": 60,
        "speedFrom": "mph",
        "speedTo": "kmh"
      },
      "expect": {
        "result": 96.56064
      },
      "source": "NIST SP 811 (2008) B.8: 1 mi = 1.609344 km exactly; 60 × 1.609344 = 96.56064 (content.mdx)"
    }
  ],
  "sources": [
    "NIST SP 811 (2008), Guide for the Use of the International System of Units, section 4.2.1.1 and Appendix B.8. https://www.nist.gov/pml/special-publication-811"
  ],
  "related": [
    "weight-converter",
    "kg-to-lbs",
    "inches-to-cm",
    "fahrenheit-to-celsius",
    "cups-to-ml"
  ],
  "changelog": []
}
