Number base converter
Convert numbers between any bases from 2 to 36, such as binary, octal, decimal and hexadecimal.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/base-convert \
-H 'Content-Type: application/json' \
-d '{"input":{"value":"ff","from_base":16,"to_base":2,"group":4}}'
import json, urllib.request
body = {'input': {'value': 'ff', 'from_base': 16, 'to_base': 2, 'group': 4}}
request = urllib.request.Request("https://setget.net/v1/tools/base-convert", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/base-convert", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"value":"ff","from_base":16,"to_base":2,"group":4}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "base-convert",
"input": {
"value": "ff",
"from_base": 16,
"to_base": 2,
"group": 4
}
}
{
"input": {
"value": "ff",
"from_base": 16,
"to_base": 2,
"group": 4
}
}
Endpoint: POST /v1/tools/base-convert. Over MCP: run_tool with slug: "base-convert".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
value |
string | yes | The number to convert. A 0x, 0b or 0o prefix is understood. |
to_base |
integer | yes | Base to convert to. From 2 to 36. |
from_base |
integer | no | Base the number is written in. Taken from the prefix, or 10, when left empty. From 2 to 36. |
prefix |
boolean | no | Add 0x, 0b or 0o to the result when the target base is 16, 2 or 8. Default: false. |
group |
integer | no | Put a space between every this many digits, counted from the right. 0 turns it off. Default: 0. From 0 to 16. |
uppercase |
boolean | no | Write letter digits in capitals. Default: false. |
precision |
integer | no | Most digits to give after the point for fractions. Default: 20. From 0 to 100. |
Examples
Input
{
"value": "ff",
"from_base": 16,
"to_base": 2,
"group": 4
}Result
{
"text": "1111 1111",
"from_base": 16,
"to_base": 2,
"decimal": "255",
"exact": true
}Decimal to hex
Input
{
"value": "-255",
"to_base": 16,
"prefix": true
}Result
{
"text": "-0xff",
"from_base": 10,
"to_base": 16,
"decimal": "-255",
"exact": true
}A fraction that never ends in binary
Input
{
"value": "0.1",
"to_base": 2,
"precision": 8
}Result
{
"text": "0.00011001",
"from_base": 10,
"to_base": 2,
"decimal": "0.1",
"exact": false
}Questions
- Why is "exact" false for 0.1 in binary?
- Like 1/3 in decimal, 0.1 has no finite form in base 2. The digits are cut off (not rounded) at "precision" places.
- How are negative numbers shown?
- With a minus sign in front. Two's complement is not used.
- Which digits do bases above 10 use?
- 0 to 9 and then a to z, so base 16 uses 0-9 and a-f, and base 36 uses 0-9 and a-z.
Related tools
- Number formatterFormat a number with thousands separators, in scientific or compact form, as an ordinal, or in words.
number-format - Roman numeral converterConvert a number to Roman numerals or Roman numerals to a number, from 1 to 3,999,999.
roman-numerals - Calculator and expression evaluatorWork out an arithmetic expression safely: brackets, powers, functions such as sqrt and log, and variables.
math-eval - Add or subtract time from a dateAdd or subtract years, months, weeks, days, hours and minutes from a date and get the resulting date.
date-add - Age calculatorWork out an exact age in years, months and days on a given date, plus the next birthday.
age-calculator - Aspect ratio calculatorSimplify a width and height to a ratio such as 16:9, and scale to a new width or height.
aspect-ratio