curatedapi

Length converter

Convert between metric, imperial/US, nautical and astronomical lengths.

The amount to convert.
Unit of the value. Options: m: metre; km: kilometre; cm: centimetre; mm: millimetre; um: micrometre; nm: nanometre; in: inch; ft: foot; yd: yard; mi: mile; nmi: nautical mile; mil: mil (thou); fathom: fathom; chain: chain; furlong: furlong; ft_us: US survey foot; au: astronomical unit; ly: light-year; pc: parsec
Unit to convert to. Omit to convert to every unit. Options: m: metre; km: kilometre; cm: centimetre; mm: millimetre; um: micrometre; nm: nanometre; in: inch; ft: foot; yd: yard; mi: mile; nmi: nautical mile; mil: mil (thou); fathom: fathom; chain: chain; furlong: furlong; ft_us: US survey foot; au: astronomical unit; ly: light-year; pc: parsec
More options: rounding and decimals
Precision and rounding
Rounding mode applied once to each result. Default half_even.
Round results to this many digits after the decimal point.
Round results to this many significant digits.

Examples

Example: One mile in kilometres

Result
The converted value.
1.609344 exact
Factor
How many to_unit make one from_unit (multiply by this to convert).
1.609344 exact

Rounding: Half even, 15 significant digits. Calculator units/length@1.

How it is calculated

result = value × factor(from_unit) ÷ factor(to_unit), factors in m

Convert between metric, imperial/US, nautical and astronomical lengths. Conversion factors are exact values from the official unit definitions, so the result is exact before the single final rounding. Leave out to_unit to get the value in every supported unit.

  • Unit definitions: 1 m = 1 m (SI base unit); 1 km = 1000 m (SI prefix); 1 cm = 0.01 m (SI prefix); 1 mm = 0.001 m (SI prefix); 1 um = 0.000001 m (SI prefix); 1 nm = 0.000000001 m (SI prefix); 1 in = 0.0254 m (international inch, exact since 1959); 1 ft = 0.3048 m (international foot = 12 in); 1 yd = 0.9144 m (international yard = 3 ft); 1 mi = 1609.344 m (international mile = 5280 ft); 1 nmi = 1852 m (international nautical mile, exact); 1 mil = 0.0000254 m (1/1000 inch); 1 fathom = 1.8288 m (6 ft); 1 chain = 20.1168 m (66 ft); 1 furlong = 201.168 m (660 ft); 1 ft_us = 1200/3937 m (1200/3937 m; retired by NIST at the end of 2022 but still in old land records); 1 au = 149597870700 m (IAU 2012 Resolution B2, exact); 1 ly = 9460730472580800 m (speed of light × Julian year (IAU)); 1 pc = see source m (648000/π au, IAU 2015 Resolution B2)

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Use it from your code

POST /v1/calc/units/lengthVersion 1
curl https://api.curatedapi.com/v1/calc/units/length \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "1",
    "from_unit": "mi",
    "to_unit": "km"
  }'
The same call in Python
import os

import requests

payload = {
    "value": "1",
    "from_unit": "mi",
    "to_unit": "km",
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/units/length",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "value": "1",
    "from_unit": "mi",
    "to_unit": "km",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/units/length", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log((await response.json()).result);

MCP tool calc_units_length at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="units/length" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>

Use a public key registered for your site. Calculations are billed like API calls. How widgets work.

Related calculators

Add this calculator to your website

Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.

Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.