Unit Converter

Convert a value between units. $0.005 per request.

What it does

Converts a numeric value between units in the same category: length, mass, volume, area, speed, time, data size, or temperature.

Endpoint

MethodPOST
Path/convert
Content-Typeapplication/json

Fields

fieldrequireddescription
valueyesNumeric value to convert
fromyesSource unit
toyesTarget unit (same category as 'from')

Supported units

length: mm, cm, m, km, in, ft, yd, mi   mass: mg, g, kg, oz, lb, ton   volume: ml, l, gal, qt, pt, cup, fl_oz

area: sqm, sqft, sqkm, acre, hectare   speed: mps, kmh, mph, knot   time: ms, s, min, hr, day, week

data: byte, kb, mb, gb, tb, kib, mib, gib   temperature: c, f, k

Example

curl -X POST https://unit-converter.pdfextractapi.workers.dev/convert \
  -H "Content-Type: application/json" \
  -d '{"value": 5, "from": "mi", "to": "km"}'

Example response

{ "value": 5, "from": "mi", "to": "km", "category": "length", "result": 8.04672 }

Errors

Errors return a non-200 status with { "error": { "code": "...", "message": "..." } }. Common codes: invalid_value, invalid_units, unknown_unit, mismatched_categories.

Payment

This endpoint is paid per-request via the x402 protocol (HTTP 402 + USDC). Unpaid requests receive a 402 response with payment instructions.

Try it in your browser