We count in decimal (base 10) because we have ten fingers. Computers count in binary (base 2) because a wire is either on or off. Programmers lean on hexadecimal (base 16) because it’s a compact, tidy way to write binary. Converting between these bases is a daily task once you work close to the metal — and it’s simpler than it looks.
What “base” actually means
A base is just how many symbols each digit can be, and how much each position is worth:
- Decimal (10): digits 0–9. Positions are 1, 10, 100, 1000…
- Binary (2): digits 0–1. Positions are 1, 2, 4, 8, 16…
- Octal (8): digits 0–7. Positions are 1, 8, 64…
- Hex (16): digits 0–9 then a–f (a=10 … f=15). Positions are 1, 16, 256…
So binary 1010 = 8 + 0 + 2 + 0 = 10 in decimal. Hex ff = 15×16 + 15 = 255.
Why hex, not just binary?
Binary is correct but unreadable — 11111111 vs ff. Because 16 is 2⁴, every hex digit maps to exactly four binary digits, so hex is a shorthand for binary with no loss. That’s why colors (#3388cc), memory addresses (0x7ffe) and Unicode code points (U+1F600) are written in hex.
The one gotcha: the same digits mean different numbers
10 is ten in decimal, two in binary, eight in octal and sixteen in hex. A string of digits is meaningless until you know its base. That’s the mistake behind most conversion errors — assuming 100 is a hundred when it’s actually binary for four.
Text is just bytes too
“Text to binary” works because every character is stored as bytes (via UTF-8), and every byte is 8 bits. The letter A is byte 65 = 01000001 in binary = 41 in hex. Emoji and non-Latin characters take several bytes, but the idea is the same.
Convert instantly, in your browser
The number base converter links all four bases: type into any field and the rest update live. It uses BigInt, so even huge numbers stay exact, and it also turns text into binary or hex (and back) using UTF-8.
Related tools
- Encoding bytes for transport? See the Base64 tool.
- Working with hex color codes? Use the color converter.
A quick reference table
Every row below is the same number in four bases — handy to keep nearby:
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 8 | 1000 | 8 | 10 |
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 64 | 1000000 | 40 | 100 |
| 100 | 1100100 | 64 | 144 |
| 128 | 10000000 | 80 | 200 |
| 255 | 11111111 | FF | 377 |
| 256 | 100000000 | 100 | 400 |
| 1024 | 10000000000 | 400 | 2000 |
The row worth memorising is 255 = 0xFF = 0b11111111 — the largest value a single byte (8 bits) can hold.
Converting by hand
- Decimal → binary: divide by 2 repeatedly and read the remainders bottom-up.
13→ 6 r1, 3 r0, 1 r1, 0 r1 →1101. - Binary → decimal: add the place values.
1101= 8 + 4 + 0 + 1 =13. - Binary ↔ hex: group the bits into nibbles of four from the right.
11111111→1111 1111→F F→FF. - Hex → decimal: multiply each digit by its power of 16.
0x2A= 2×16 + 10 =42.
What the prefixes mean
Because the same digits mean different numbers, code marks the base with a prefix: 0x for hex (0xFF), 0b for binary (0b1010), and 0o (or a bare leading zero in C) for octal (0o17). No prefix means decimal. When you’d rather not do any of this by hand, the guide to CSS color formats shows the same hex at work in web colors.