Skip to content
ToolsOnDuty - free online tools
ToolsOnDuty / docs
Browse documentation

Reference / Converters

Converters API

21 endpoints for converters workflows. Every call requires bearer authentication and uses the standard ToolsOnDuty response envelope.

Try it

Runs a real request from your browser to your own ToolsOnDuty account. Your key is only kept in this page and is never stored.

POST/v1/convert/text-hex1 credit / call

Text <-> hex

Convert text to a hex byte sequence, or decode a hex byte sequence back to text.

ParameterTypeRequiredDescription
textstringYesmode=encode: plain text. mode=decode: hex string.
modestringNoencode | decode. Default: encode.
separatorstringNoSeparator between hex bytes when encoding. Default: .

Request

curl -X POST https://toolsonduty.com/api/v1/convert/text-hex \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"text":"hi"}'

Response

{
  "ok": true,
  "data": {
    "result": "68 69"
  }
}
POST/v1/convert/text-codepoints1 credit / call

Text <-> Unicode code points

Convert text to space-separated Unicode code points (U+XXXX), or decode them back to text.

ParameterTypeRequiredDescription
textstringYesmode=encode: plain text. mode=decode: code points.
modestringNoencode | decode. Default: encode.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/text-codepoints \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"text":"hi"}'

Response

{
  "ok": true,
  "data": {
    "result": "U+0068 U+0069"
  }
}
POST/v1/convert/base1 credit / call

Number base converter

Convert an arbitrary-size integer written in any base (2-36) into binary, octal, decimal and hex.

ParameterTypeRequiredDescription
valuestringYesThe number to convert, as a string.
fromBasenumberNoSource base (2-36). Default: 10.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/base \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"value":"255","fromBase":10}'

Response

{
  "ok": true,
  "data": {
    "binary": "11111111",
    "octal": "377",
    "decimal": "255",
    "hex": "ff"
  }
}
POST/v1/convert/roman-numeral1 credit / call

Roman numeral converter

Convert a whole number (1-3999) to a Roman numeral, or a Roman numeral back to a number.

ParameterTypeRequiredDescription
valuestringYesmode=encode: whole number. mode=decode: Roman numeral.
modestringNoencode | decode. Default: encode.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/roman-numeral \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"value":"1994"}'

Response

{
  "ok": true,
  "data": {
    "result": "MCMXCIV"
  }
}
POST/v1/convert/unit1 credit / call

Unit converter

Convert a value between units within a category (length, weight, temperature, area, volume, speed, time, digital-storage, data-rate, pressure, energy, power, angle, fuel-economy, frequency), returning every unit in that category.

ParameterTypeRequiredDescription
categorystringYesCategory id: length, weight, temperature, area, volume, speed, time, digital-storage, data-rate, pressure, energy, power, angle, fuel-economy, frequency.
valuenumberYesValue to convert.
fromstringYesSource unit id.
tostringYesTarget unit id.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/unit \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"category":"length","value":1,"from":"mi","to":"km"}'

Response

{
  "ok": true,
  "data": {
    "result": 1.609344
  }
}
POST/v1/convert/cooking1 credit / call

Cooking measurement converter

Convert a cooking amount between volume and/or mass units using an ingredient's density. Results are approximate.

ParameterTypeRequiredDescription
ingredientstringYesIngredient id: water, milk, flour, sugar, brown-sugar, butter, oil, honey, salt, rice, cocoa.
valuenumberYesAmount to convert.
fromstringYesSource unit id (cup, tbsp, tsp, floz, ml, l, g, kg, oz, lb).
tostringYesTarget unit id.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/cooking \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"ingredient":"flour","value":1,"from":"cup","to":"g"}'

Response

{
  "ok": true,
  "data": {
    "result": 125.15
  }
}
POST/v1/color/convert1 credit / call

Color format converter

Convert a HEX color, rgb() value or CSS color name into HEX, RGB, HSL, HSV and CMYK.

ParameterTypeRequiredDescription
colorstringYesHEX color, rgb() value or CSS color name.

Request

curl -X POST https://toolsonduty.com/api/v1/color/convert \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"color":"#ff0000"}'

Response

{
  "ok": true,
  "data": {
    "hex": "#ff0000",
    "rgb": "rgb(255, 0, 0)",
    "hsl": "hsl(0, 100%, 50%)"
  }
}
POST/v1/color/name-to-hex1 credit / call

CSS color name to HEX

Look up the HEX value for one of the 147 standard CSS color names.

ParameterTypeRequiredDescription
namestringYesCSS color name, e.g. "cornflowerblue".

Request

curl -X POST https://toolsonduty.com/api/v1/color/name-to-hex \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"name":"cornflowerblue"}'

Response

{
  "ok": true,
  "data": {
    "hex": "#6495ed"
  }
}
POST/v1/color/nearest-name1 credit / call

Nearest CSS color name

Find the closest of the 147 standard CSS color names to a HEX value, by RGB distance.

ParameterTypeRequiredDescription
hexstringYesHEX color, e.g. #6495ed.

Request

curl -X POST https://toolsonduty.com/api/v1/color/nearest-name \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"hex":"#6495ed"}'

Response

{
  "ok": true,
  "data": {
    "name": "cornflowerblue",
    "exact": true
  }
}
POST/v1/convert/number-words1 credit / call

Number <-> words

Spell a number out in English words, or parse English number words back into a number.

ParameterTypeRequiredDescription
textstringYesmode=to-words: a number. mode=to-number: number words.
modestringNoto-words | to-number. Default: to-words.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/number-words \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"text":"1234","mode":"to-words"}'

Response

{
  "ok": true,
  "data": {
    "result": "One thousand two hundred thirty-four"
  }
}
POST/v1/convert/scientific-notation1 credit / call

Scientific notation converter

Convert a number into standard, scientific, e-notation and engineering forms.

ParameterTypeRequiredDescription
valuestringYesA number, e.g. 1234 or 1.23e4.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/scientific-notation \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"value":"1234"}'

Response

{
  "ok": true,
  "data": {
    "standard": "1234",
    "scientific": "1.234 × 10^3",
    "eNotation": "1.234e+3"
  }
}
POST/v1/convert/fraction-decimal1 credit / call

Fraction <-> decimal

Convert a terminating decimal to a simplified fraction and mixed number, or a fraction/mixed number to a decimal.

ParameterTypeRequiredDescription
textstringYesmode=to-fraction: a decimal like 0.75. mode=to-decimal: a fraction like 3/4 or 1 1/2.
modestringNoto-fraction | to-decimal. Default: to-fraction.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/fraction-decimal \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"text":"0.75","mode":"to-fraction"}'

Response

{
  "ok": true,
  "data": {
    "decimal": "0.75",
    "fraction": "3/4",
    "mixed": "3/4"
  }
}
POST/v1/convert/xml-format1 credit / call

XML formatter

Pretty-print (indent) an XML document. Formatting only; does not validate the XML.

ParameterTypeRequiredDescription
xmlstringYesXML text to format.
indentSizenumberNoSpaces per indent level. Default: 2.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/xml-format \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<a><b>1</b></a>"}'

Response

{
  "ok": true,
  "data": {
    "result": "<a>\n<b>1</b>\n</a>"
  }
}
POST/v1/convert/date-format1 credit / call

Date format converter

Parse a date (ISO text, common locale strings, or a Unix timestamp) and render it in many common formats, plus an optional custom pattern.

ParameterTypeRequiredDescription
datestringYesA date like 2024-01-31, 01/31/2024, or a Unix timestamp.
customPatternstringNoAn optional date-fns format pattern, e.g. "yyyy/MM/dd".

Request

curl -X POST https://toolsonduty.com/api/v1/convert/date-format \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"date":"2024-01-31"}'

Response

{
  "ok": true,
  "data": {
    "forms": [
      {
        "label": "ISO date",
        "value": "2024-01-31"
      }
    ]
  }
}
POST/v1/convert/file-size1 credit / call

File size formatter

Format bytes as readable binary or decimal units.

ParameterTypeRequiredDescription
bytesnumberYesNon-negative byte count.
decimalsnumberNoDecimal places from 0 to 10. Default: 2.
binarybooleanNoUse base-1024 IEC units. Default: true.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/file-size \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"bytes":1536000,"binary":true}'

Response

{
  "ok": true,
  "data": {
    "value": 1.46,
    "unit": "MiB",
    "formatted": "1.46 MiB"
  }
}
POST/v1/convert/punycode1 credit / call

Punycode converter

Encode an internationalized hostname as ASCII or decode xn-- labels to Unicode.

ParameterTypeRequiredDescription
domainstringYesHostname without protocol or path.
modestringNoencode | decode. Default: encode.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/punycode \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"domain":"münich.example","mode":"encode"}'

Response

{
  "ok": true,
  "data": {
    "result": "xn--mnich-kva.example"
  }
}
POST/v1/convert/unicode-escape1 credit / call

Unicode escape converter

Escape non-ASCII characters as Unicode sequences or restore supported sequences.

ParameterTypeRequiredDescription
textstringYesText or Unicode escape sequences.
modestringNoescape | unescape. Default: escape.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/unicode-escape \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hi 👋","mode":"escape"}'

Response

{
  "ok": true,
  "data": {
    "result": "Hi \\u{1f44b}"
  }
}
POST/v1/convert/html-to-text1 credit / call

HTML to text

Strip HTML markup, scripts and styles while preserving common block breaks.

ParameterTypeRequiredDescription
htmlstringYesHTML fragment or document.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/html-to-text \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Hello</h1><p>World</p>"}'

Response

{
  "ok": true,
  "data": {
    "result": "Hello\nWorld"
  }
}
POST/v1/convert/latlon-utm1 credit / call

Latitude/longitude to UTM

Convert WGS84 latitude and longitude to UTM zone, hemisphere, easting and northing.

ParameterTypeRequiredDescription
latitudenumberYesLatitude from -80 to 84.
longitudenumberYesLongitude from -180 to 180.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/latlon-utm \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"latitude":28.6139,"longitude":77.209}'

Response

{
  "ok": true,
  "data": {
    "zone": 43,
    "hemisphere": "N"
  }
}
POST/v1/convert/ring-size1 credit / call

Ring size converter

Convert US ring size, inside diameter or circumference to the nearest standard size.

ParameterTypeRequiredDescription
valuenumberYesRing size measurement.
systemstringNous | diameter-mm | circumference-mm. Default: us.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/ring-size \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"value":7,"system":"us"}'

Response

{
  "ok": true,
  "data": {
    "us": 7
  }
}
POST/v1/convert/shoe-size1 credit / call

Shoe size converter

Approximately convert adult US men's, US women's, UK, EU and centimeter shoe sizes.

ParameterTypeRequiredDescription
valuenumberYesShoe size measurement.
systemstringNous-men | us-women | uk | eu | cm. Default: us-men.

Request

curl -X POST https://toolsonduty.com/api/v1/convert/shoe-size \
  -H "Authorization: ******" \
  -H "Content-Type: application/json" \
  -d '{"value":9,"system":"us-men"}'

Response

{
  "ok": true,
  "data": {
    "usMen": 9
  }
}