Convert a number between binary, octal, decimal and hexadecimal
- Dashboard
- Documentation
- API
Why use a number converter?
Conversion between bases (binary, octal, hexadecimal, decimal) is a common need in low-level programming, electronics, cryptography and data analysis. This tool converts a number to all four bases at once, without having to specify the input format.
Automatic detection of the input format
The tool detects the input base automatically:
- Prefix
0b: binary (e.g.0b101010) - Prefix
0o: octal (e.g.0o52) - Prefix
0x: hexadecimal (e.g.0x2a) - Without prefix and containing letters a-f: hexadecimal (e.g.
2a,ff) - Without prefix and digits only: decimal (e.g.
42)
How to use the tool
Enter a number in the input field then click "Convert". The four representations (binary, octal, hexadecimal, decimal) will display simultaneously. You can then copy the result with the dedicated button.
Example
Input: 0b101010
Results:
binary: 101010
octal: 52
hexadecimal: 2a
decimal: 42
Frequently asked questions
What prefixes are accepted to distinguish bases?
The tool recognises standard conventions: 0b for binary (e.g. 0b101010), 0o for octal (e.g. 0o52), 0x for hexadecimal (e.g. 0x2a). Without a prefix, a number with digits only is interpreted as decimal, and a number containing letters a to f is interpreted as hexadecimal. This convention is compatible with Python, JavaScript and most modern languages.
Why convert between binary, octal, hexadecimal and decimal?
Different bases serve different contexts. Binary accurately represents the memory structure (bits, flags, masks). Hexadecimal compresses 4 bits per character, ideal for reading memory addresses, colours (#ff6600), hashes or UUIDs. Octal still appears on Unix permissions (chmod 755). Decimal is the everyday human base. Converting between these bases is essential in low-level work, security and networking.
What is the difference between base 2, base 8, base 16 and base N?
A numeral system's base indicates how many distinct symbols it uses. Base 2 (binary) uses 0 and 1, base 8 (octal) digits 0 to 7, base 10 (decimal) digits 0 to 9, base 16 (hexadecimal) adds a to f. Any base N follows the same principle: N symbols, and each position is worth N^k. This tool targets the four common bases (2, 8, 10, 16).
Does the tool handle negative or decimal numbers?
The current version focuses on positive integers, which cover most needs in systems programming. Negative numbers are expressed in two's complement based on a fixed word width (8, 16, 32, 64 bits) and require additional context. Decimal numbers in binary (IEEE 754) are a separate subject. For these cases, use printf, bc at the command line, or a dedicated IEEE 754 tool.
How do I manually convert between binary and hexadecimal?
Binary to hexadecimal conversion is trivial because 4 bits equal exactly one hex digit. Split the binary into groups of 4 bits from the right and replace each group with its hex equivalent: 0000 gives 0, 1010 gives a, 1111 gives f. Example: 10101010 splits into 1010 1010 and equals aa. The reverse direction is just as direct.
Why does my hexadecimal number ff give 255 in decimal?
In hexadecimal, each digit represents a power of 16. ff equals f * 16 + f * 1, that is 15 * 16 + 15 = 255. This is the maximum value of one byte (8 bits), which is why ff is omnipresent in programming: maximum intensity of a colour channel (#ff0000 pure red), full mask, sentinel value.
Example request
curl -X POST https://cdrn.fr/api/v1/tools/number-converter/execute \
-H "Content-Type: application/json" \
-d '{"number":"..."}'
Input schema
| Field | Type | Required | Default |
|---|---|---|---|
number |
string | ✓ | – |
Endpoints
GET https://cdrn.fr/api/v1/tools- lists every available toolGET https://cdrn.fr/api/v1/tools/number-converter- returns the schema for this toolPOST https://cdrn.fr/api/v1/tools/number-converter/execute- runs this tool with a JSON payload