
Number Base Converter API
Development
Convert numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, with exact results for huge and negative numbers and a two's complement view.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Converts a whole number of any size between bases 2 and 36 using exact BigInt maths. Every response includes the number in binary, octal, decimal and hexadecimal. You can add one more target base and a two's complement view.
Input rules
valueis a string, because large numbers do not fit in a JSON number.- It is read in
fromBase(default 10). Digits above 9 are the letters a-z, in either case. - A leading + or -, a matching 0x, 0b or 0o prefix, and spaces, underscores, commas or apostrophes as digit separators are accepted.
- Whole numbers only. Fractions are rejected. Up to 20,000 digits.
Output
binary,octal,decimal,hexadecimal: the number as strings, with a leading - when negative.bitLength: number of binary digits in the absolute value (0 for zero).toBase: present when you passtoBase.twosComplement: present when you passtwosComplementBits. Values from -2^(n-1) to 2^n - 1 fit. When the value does not fit, you getfits: falsewith the allowedminandmax.
Endpoints
POST
https://opentools.ca/api/v1/tools/number-base-converterConvert a whole number between bases
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | Required | The number to convert, written in fromBase. |
| fromBase | number | Optional | Base of the input, an integer from 2 to 36.Default: 10 |
| toBase | number | Optional | One extra base to convert to, an integer from 2 to 36. Returned as toBase. |
| uppercase | boolean | Optional | Use capital letters for digits above 9 in the hexadecimal and toBase results.Default: false |
| group | boolean | Optional | Group digits for readability: 4 for binary and hex, 3 for octal, and commas for decimal.Default: false |
| twosComplementBits | number Enum: 8, 16, 32, 64 | Optional | Add a two's complement view at this bit width. |
Response Example
{
"success": true,
"input": "255",
"fromBase": 10,
"binary": "11111111",
"octal": "377",
"decimal": "255",
"hexadecimal": "ff",
"bitLength": 8,
"toBase": {
"base": 36,
"value": "73"
},
"twosComplement": {
"bits": 8,
"fits": true,
"binary": "11111111",
"hexadecimal": "ff",
"signed": "-1",
"unsigned": "255"
}
}Error Codes
400
Bad Request - Empty value, a digit that is not valid in fromBase, a fraction, or a base or width out of range401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed for this key429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/number-base-converter -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{
"value": "255",
"fromBase": 10,
"toBase": 36,
"twosComplementBits": 8
}'Rather use it in your browser? Open the Number Base Converter