How to use the number base converter
- Choose the base your number is written in, then type it. Prefixes such as 0x, 0b and 0o are recognised, as are spaces, underscores and commas between digits.
- Read the binary, octal, decimal and hexadecimal results at once. Pick an Extra base to see, for example, base 36 or base 3 as well.
- Turn on grouping by nibbles or bytes to make long binary and hex values readable, and choose uppercase or lowercase letters.
- Copy any result with the button next to it.
Features
- Exact conversion of numbers of any size using BigInt, not floating point
- All common bases shown at once, plus any custom base from 2 to 36
- Validation that names the offending digit for the chosen base
- Nibble and byte grouping, optional 0x/0b/0o prefixes, uppercase or lowercase
- Bit length, sign and two's-complement representation for negative values
How positional bases work
In base b, each digit position is worth a power of b: the hexadecimal number 2F means 2 × 16 + 15 = 47. Bases above 10 use letters for the extra digits, A = 10 up to Z = 35, which is why base 36 is the largest base representable with digits and the Latin alphabet. Binary, octal and hex are popular because each octal digit is exactly 3 bits and each hex digit exactly 4, so converting between them is a matter of grouping bits.
Why BigInt matters
JavaScript's normal numbers are 64-bit floats that only represent integers exactly up to 2^53 (about 9 quadrillion). Snowflake IDs, Ethereum addresses, SHA-256 digests and IPv6 addresses are all bigger than that, and a converter using floating point silently rounds them. This tool uses BigInt so every digit is preserved regardless of size.
Negative numbers and two's complement
Mathematically, -5 in binary is simply -101. Computers instead store negatives in two's complement within a fixed width: -5 as an 8-bit value is 11111011 (0xFB). When the input is negative, the tool shows the smallest standard width (8, 16, 32, 64, 128 or 256 bits) that fits and the corresponding two's-complement value, which is what you'll see in a debugger or a packet dump.