How to convert units of measurement with an API

Updated 2026-11-10

Use when an agent must convert a quantity between units such as length, mass, temperature or data size.

From an MCP client, add https://tanod.dev/mcp and call convert_units; its free daily calls are applied automatically, no key or signup.

POST a value, a from unit and a to unit to /v1/convert/units. It returns the result, the category and the exact factor used. About 130 units in 12 categories: length, mass, temperature, volume (metric, US and imperial), area, speed, pressure, energy, power, data size (SI and IEC), time and fuel economy.

When to use it, and when not

Use it when a unit conversion has to be exact and explained: the response names the factor and the formula, so an agent can show its working instead of trusting arithmetic done in a prompt. It suits data sizes (kB against KiB), fuel economy and temperature, where a plain multiplication gives wrong answers.

Do not use it for currency; use the exchange rates route (/v1/fx). Do not use it for time zones; use /v1/time. Mach is not offered, because it depends on altitude.

Request

A JSON body with three required fields. No other fields are accepted.

FieldTypeMeaning
valuenumberThe number to convert, at most 1e300 in magnitude.
fromstring, 1-32 charactersSource unit, a symbol or name such as in, kg, C, psi, kB, mpg.
tostring, 1-32 charactersTarget unit, in the same category as from.
curl, using the free tier
curl -s -X POST https://tanod.dev/v1/convert/units \
  -H 'content-type: application/json' -H 'X-Tanod-Free: 1' \
  -d '{"value":1,"from":"in","to":"cm"}'

Response

Response (the example from the OpenAPI spec)
{"value": 1.0, "result": 2.54, "from": "in", "from_name": "inch",
 "to": "cm", "to_name": "centimetre", "category": "length",
 "kind": "multiply", "formula": "result = value * factor",
 "factor": 2.54, "factor_decimal": "2.54", "factor_exact": true}

kind is multiply, affine (temperature) or reciprocal (fuel economy). factor_decimal gives every digit when the factor terminates, otherwise 34 significant digits. Temperature results add offset, offset_decimal and offset_exact.

Conversion rules

Factors are exact definitions (an inch is exactly 0.0254 m, a pound exactly 0.45359237 kg, a US gallon 231 cubic inches). Temperature uses offsets, not factors. Fuel economy between mpg and L/100 km is a reciprocal. Case matters only where it must (kB against kb, MB against Mb). gal, qt, pt, cup and fl_oz are US units; the imperial ones end in _imp. cal is the thermochemical calorie (4.184 J) and BTU the IT BTU. Unit codes are listed in the OpenAPI document.

Errors

These are a 422 returned before any payment, so they are not charged:

An unpaid call without the X-Tanod-Free: 1 header, or with missing or invalid input, gets a 402 that quotes the price and names the problem in error. The free header must be sent on an unpaid HTTP call; over MCP it is applied automatically. Typical latency is under 0.1 s.

Price and free allowance

USD 0.001 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. 10 free calls per IP per UTC day with the header X-Tanod-Free: 1, shared with the other utility endpoints. MCP tool: convert_units at https://tanod.dev/mcp (also on /mcp/util), where the free tier is automatic.

Pricing →

Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/util?via=unit-conversion-api as a custom connector (steps), then ask in plain words, for example "Convert 26.2 miles to kilometres." The free daily allowance is applied automatically over MCP. Beyond it a call needs an x402 payment, which these clients can make.

Related guides: Hash text API, Time zone converter API. Back to tanod.dev or the guide index.