Skip to content

Base Conversion

The /base endpoint converts a number from one numeric base to another, anywhere between base 2 and base 36.

How it works?

Digits are read as 0-9 then a-z, representing the values 0 to 35, so input is case-insensitive and the result is always lowercase. The conversion uses arbitrary-precision integers: values far beyond Number.MAX_SAFE_INTEGER keep every digit intact. A leading minus sign is preserved, except when the value is zero (-0 returns 0).

Parameters

ParameterRequiredDescription
valueYesNumber to convert, optionally prefixed with -. Up to 100 characters, valid for the from base
fromNoInput base, an integer between 2 and 36. Default: 10
toNoOutput base, an integer between 2 and 36. Default: 16

Response Fields

FieldTypeDescription
valuestringThe original input value, as provided
fromnumberInput base used for the conversion
tonumberOutput base used for the conversion
resultstringThe converted value, in lowercase digits

Code Examples

curl -X GET \
  "https://api.sylvain.sh/v5/base?value=255&from=10&to=16"

Try It

Error Handling

If parameters are missing or invalid, the API will return an error:

Error MessageDescription
Please provide a value (?value={value})The value parameter is missing
Value must be 100 characters or fewerThe value exceeds the maximum length
Base must be a numberfrom or to is not an integer
Base must be between 2 and 36from or to is outside the supported range
Invalid value for base {from}A digit of value does not exist in the input base, or value is only a minus sign