About the Binary Converter API

API Version: 1.9

The Binary Converter allows you to convert numbers between different bases: binary, octal, decimal, and hexadecimal.

This is the API for the Binary Converter.

Endpoints

https://networkcalc.com/api/binary/{number}

Converts numbers between binary, octal, decimal, and hexadecimal.

Example request and response
curl https://networkcalc.com/api/binary/1e7d6d?from=16&to=2

{
  "status": "OK",
  "original": "1e7d6d",
  "converted": "111100111110101101101",
  "from": "16",
  "to": "2"
}

Parameters

{number}

(Required) The number to convert from. May be specified as a binary, octal, decimal, or hexadecimal number.

Example: https://networkcalc.com/api/binary/00001010

from

(Optional) The radix (base) to convert from.

Values: 2,8,10,16

Example: https://networkcalc.com/api/binary/1e7d6d?from=16

to

(Optional) The radix (base) to convert to.

Values: 2,8,10,16

Example: https://networkcalc.com/api/binary/00001010?to=16

signed

(Optional) Use two's complement. Non-decimal input is read as a two's complement bit pattern, decimal input may be negative, and non-decimal output is zero-padded to bit_width bits.

Values: true

Example: https://networkcalc.com/api/binary/-5?from=10&to=2&signed=true

bit_width

(Optional) The width in bits for signed=true. Defaults to 8.

Values: 8,16,32,64

Example: https://networkcalc.com/api/binary/-5?from=10&to=2&signed=true&bit_width=16

Response Codes

200
OK - Success.
400
NO_NUMBER_SPECIFIED - The {number} parameter is missing.
400
INVALID_NUMBER_FORMAT - The {number} parameter is malformed.
400
INVALID_FROM_BASE - The from parameter is is not valid.
400
INVALID_TO_BASE - The to parameter is not valid.
400
INVALID_BIT_WIDTH - The bit_width parameter is not 8, 16, 32 or 64.
400
OUT_OF_RANGE_FOR_BIT_WIDTH - With signed=true, the value does not fit in bit_width bits.

Response Formats

{
  "status": "[string] The status of the request.",
  "from": "[string] The number to convert from.",
  "to": "[string] The converted number or null."
}