Number Base Converter
Convert between binary, octal, decimal, and hexadecimal. See all four bases at once. Supports large numbers.
What the converter does
Choose the base you are typing in, enter a value, and all four representations appear together rather than one at a time — so you can read the binary and the hex of the same number side by side. Everything runs in the page on BigInt; nothing is uploaded.
- No size ceiling —
BigIntmeans no 64-bit wrap and no float rounding. - Spaces ignored — paste
1010 0110orDE AD BE EFas-is. - Per-base validation — a
9typed while octal is selected is rejected with a message rather than silently coerced. - Copy each result — one button per base.
The four bases at a glance
| Base | Digits | Prefix | 255 is | Where you meet it |
|---|---|---|---|---|
| Binary (2) | 0–1 | 0b | 11111111 | Bitmasks, flags, permissions |
| Octal (8) | 0–7 | 0o | 377 | Unix file modes (chmod 755) |
| Decimal (10) | 0–9 | — | 255 | Everything human-facing |
| Hex (16) | 0–9, a–f | 0x | ff | Colours, memory, hashes, bytes |
Why hex maps so neatly onto bytes
One hex digit covers exactly four bits, so two hex digits are exactly one byte — always, with no padding maths. That is the whole reason hex won over octal for byte-oriented work: #ff5733 is three bytes of colour, a MAC address is six, a SHA-256 digest is thirty-two. Reading the same value in binary shows you which bits are set; reading it in hex shows you where the byte boundaries are.
Converting bases in code
// JavaScript — always pass the radix
parseInt("ff", 16) // 255
parseInt("11111111", 2) // 255
(255).toString(16) // "ff"
(255).toString(2) // "11111111"
BigInt("0xff") // 255n — for values beyond 2^53
// Python
int("ff", 16) # 255
bin(255) # '0b11111111'
hex(255) # '0xff'
f"{255:08b}" # '11111111' — zero-padded
// Shell
printf '%x\n' 255 # ff
echo $((16#ff)) # 255Common base-conversion mistakes
- Forgetting the radix —
parseInt("0x10")returns 16, because the prefix makes it guess hex even when you meant a decimal string. Always pass the second argument. - Leading zeros meaning octal — in older JS, Python 2, and many config formats,
0755is octal. A zip code stored as a number is how this bites. - Precision loss past 2^53 — JavaScript numbers are doubles, so a 19-digit ID silently rounds. This page uses
BigIntfor exactly that reason. - Assuming a fixed width —
11111111is 255 in eight bits and also 255 in thirty-two. Padding is a display choice, not part of the value.
Related number & byte tools
Frequently Asked Questions
Which bases are supported?
Binary (2), octal (8), decimal (10), and hexadecimal (16). Pick the base you are typing in and all four appear at once, each with its own copy button.
Does it handle very large numbers?
Yes. Conversion runs on BigInt, so there is no 64-bit ceiling and no precision loss the way there would be with a float. Paste a 200-digit value if you like.
Can I convert negative or fractional numbers?
No — input must be a non-negative integer. A minus sign or a decimal point is rejected as invalid for the selected base.
Why is hexadecimal everywhere in programming?
One hex digit is exactly four bits, so a byte is always two hex digits. That clean mapping is why colours, memory addresses, MAC addresses, and hashes are all written in hex.
Do I need to include a 0x or 0b prefix?
No. Select the base with the buttons and enter bare digits. Spaces are ignored, so you can group binary as 1010 0110 for readability.