Number Base Conversion
Convert integers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16).
Overview
Use Cases
- Developer tools and calculators
- Converting memory addresses or CPU flags between hex and binary
- Teaching or learning number systems
- Debugging low-level protocol data
Features
Supports binary, octal, decimal, and hexadecimal
Accepts optional base prefixes (0x, 0b, 0o)
Supports negative integers
Fast, in-memory only β no database required
API Endpoints
Convert Base
Convert an integer from one number base to another.
GET
https://api.requiems.xyz/v1/convert/base
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| from | integer |
Required | Source base (2, 8, 10, or 16) |
| to | integer |
Required | Target base (2, 8, 10, or 16) |
| value | string |
Required | The number as a string. Accepts optional prefixes: 0x (hex), 0b (binary), 0o (octal). |
Try it out
Live DemoRequest
Source base (2, 8, 10, or 16)
Target base (2, 8, 10, or 16)
The number as a string. Accepts optional prefixes: 0x (hex), 0b (binary), 0o (octal).
Sending request...
Response Fields
| Field | Type | Description |
|---|---|---|
| input | string |
The original value as provided in the request |
| from | integer |
The source base |
| to | integer |
The target base |
| result | string |
The converted value in the target base |
Code Examples
# Decimal to hex
curl "https://api.requiems.xyz/v1/convert/base?from=10&to=16&value=255" \
-H "requiems-api-key: YOUR_API_KEY"
# Hex to binary (using 0x prefix)
curl "https://api.requiems.xyz/v1/convert/base?from=16&to=2&value=0xff" \
-H "requiems-api-key: YOUR_API_KEY"
import requests
url = "https://api.requiems.xyz/v1/convert/base"
headers = {"requiems-api-key": "YOUR_API_KEY"}
params = {"from": 10, "to": 16, "value": "255"}
response = requests.get(url, params=params, headers=headers)
print(response.json()["data"]["result"]) # ff
const params = new URLSearchParams({ from: 10, to: 16, value: '255' });
const response = await fetch(
`https://api.requiems.xyz/v1/convert/base?${params}`,
{ headers: { 'requiems-api-key': 'YOUR_API_KEY' } }
);
const { data } = await response.json();
console.log(data.result); // ff
require 'net/http'
require 'json'
uri = URI('https://api.requiems.xyz/v1/convert/base')
uri.query = URI.encode_www_form(from: 10, to: 16, value: '255')
request = Net::HTTP::Get.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts JSON.parse(response.body)['data']['result'] # ff
Error Responses
bad_request
A required parameter is missing, the base is not one of 2/8/10/16, or value is not valid for the given base.
Frequently Asked Questions
Binary (2), octal (8), decimal (10), and hexadecimal (16). Passing any other value for from or to returns a 400 error.
Yes. The API strips common base prefixes before parsing, so 0xff, 0b11111111, and 0o377 are all accepted.
Yes. A leading minus sign is preserved β for example, -255 in decimal converts to -ff in hexadecimal.
Lower case. The API uses Go's standard strconv.FormatInt which produces lower-case hex digits (aβf).