How to Convert Hexadecimal to Decimal, Binary, and Octal
Hexadecimal looks cryptic until you see the one idea underneath it: every hex digit is exactly four bits. Once that clicks, converting between hex, decimal, binary, and octal becomes a mechanical process you can do on paper — and the “magic” of colour codes, memory addresses, and byte values disappears with it.
Key takeaways
- One hex digit always equals four binary digits (bits) — that fixed grouping is why hex is the shorthand for binary.
- Hex to decimal is positional: multiply each digit by 16 raised to its place value and add; decimal to hex is repeated division by 16, reading remainders backwards.
- Hex to binary is a digit-by-digit lookup (no arithmetic); hex to octal goes through binary, regrouped in threes.
Why hex exists at all
Computers store everything in binary — strings of 0s and 1s. Binary is precise and unreadable: a single byte, 10110101, is easy to mistype and hard to scan. Decimal is readable but converts to binary awkwardly, because 10 is not a power of 2. Hexadecimal solves both problems at once: base 16 is a power of 2 (2⁴), so it converts to binary cleanly, and it is compact — one byte needs just two hex digits instead of eight bits.
Hex digits run 0–9 and then A–F, where A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15. That is the only new fact to memorise. Everything else is place value, the same idea decimal uses: in 247, the 2 means 2 × 100 because of where it sits. In hex, each place is worth sixteen times the one to its right instead of ten times.
You meet hex everywhere without noticing. Web colours like #1D6FF2 are three bytes (red, green, blue) written as six hex digits. Memory addresses, Unicode code points (U+00E9 for é), error codes, and cryptographic hashes are all hex because engineers need binary values humans can read, copy, and compare at a glance.
Hex to decimal, step by step
Write the hex number out and label each digit with its place value, starting from 0 at the rightmost digit. Multiply each digit by 16 raised to its place, then add. Worked example: convert 2F7 to decimal.
2F7 = 2 × 16² + F × 16¹ + 7 × 16⁰ = 2 × 256 + 15 × 16 + 7 × 1 = 512 + 240 + 7 = 759
A longer one, the colour-code byte pair FF: F × 16 + F = 240 + 15 = 255, which is why 255 — the maximum value of one byte — appears as FF in hex. And 1A3C: 1 × 4096 + 10 × 256 + 3 × 16 + 12 = 4096 + 2560 + 48 + 12 = 6716. The method never changes; only the powers grow. If you are converting by hand, write the powers (1, 16, 256, 4096, 65536) above the digits first — most errors come from misaligning places, not from arithmetic.
| Hex digit | Decimal | Four bits |
|---|---|---|
| 0–9 | 0–9 | 0000–1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Decimal to hex, step by step
Going the other way, divide by 16 repeatedly and keep the remainders. When the quotient reaches 0, read the remainders from last to first. Convert 759 to hex: 759 ÷ 16 = 47 remainder 7; 47 ÷ 16 = 2 remainder 15 (F); 2 ÷ 16 = 0 remainder 2. Reading upwards: 2F7. Check: it matches the previous section, as it must.
Another: 255 ÷ 16 = 15 remainder 15, so the remainders are F and F — FF, as expected. And 6716: 6716 ÷ 16 = 419 remainder 12 (C); 419 ÷ 16 = 26 remainder 3; 26 ÷ 16 = 1 remainder 10 (A); 1 ÷ 16 = 0 remainder 1. Reading upwards: 1A3C. The check step — converting back — takes ten seconds and catches the classic error of reading remainders top-to-bottom instead of bottom-to-top.
Hex to binary: the four-bit trick
This is the conversion hex was invented for, and it needs no arithmetic at all. Replace each hex digit with its four-bit group from the table above, then join the groups. Convert 2F7: 2 → 0010, F → 1111, 7 → 0111, giving 001011110111. Drop the leading zeros if you like: 1011110111.
Binary to hex is the same trick in reverse, and it is where people slip: group the bits in fours starting from the RIGHT, not the left, padding the leftmost group with leading zeros if it comes up short. Binary 1011110111 has ten bits, so pad to twelve — 0010 1111 0111 — and read off 2F7. Grouping from the left instead gives 1011 1101 11, which misaligns every digit after the first.
Why four bits and not three or five? Because 16 = 2⁴. One hex digit carries exactly the information of four bits — no waste, no overlap. That is also why a byte (eight bits) is exactly two hex digits, and why hex dumps line up so neatly: each pair of characters is one byte.
Hex to octal, via binary
Octal is base 8, or 2³, so it groups bits in threes rather than fours. There is no direct digit-to-digit map between hex and octal, so go through binary: hex → binary (fours), regroup the binary in threes from the right, then read each trio as an octal digit (000 = 0 through 111 = 7).
Convert 2F7 to octal: binary is 001011110111. Regrouped in threes from the right: 001 011 110 111 → 1, 3, 6, 7, so 1367 in octal. Check in decimal: 1 × 512 + 3 × 64 + 6 × 8 + 7 = 512 + 192 + 48 + 7 = 759, which matches the decimal value of 2F7. Octal survives mainly in Unix file permissions (755, 644) — the same regrouping idea, applied to nine permission bits in three trios.
The five mistakes everyone makes
- Reading A–F as 1–6. A is 10, not 1. The letters continue the digits, they do not restart them.
- Reading decimal-to-hex remainders top-to-bottom. The first remainder is the rightmost digit. Always read upwards.
- Grouping binary from the left. Place value lives on the right. Pad on the left, group from the right.
- Forgetting that hex is case-insensitive. 2f7 and 2F7 are the same number; 0x2F7 is the same number with a “this is hex” prefix.
- Treating the 0x prefix as a digit. 0x is a label, not part of the value. 0x10 is sixteen, not “zero times something”.
With those five avoided, every conversion in this guide is mechanical. If a result looks wrong, convert it back — the round trip is the cheapest proof in all of number-base arithmetic, and the hexadecimal calculator on this site performs it instantly for any length of input.
Frequently asked questions
How do you convert hexadecimal to decimal?
Multiply each hex digit by 16 raised to its place value (0 from the right) and add. For example, 2F7 = 2 × 256 + 15 × 16 + 7 = 759. Letters A–F count as 10–15.
What is the fastest way to convert hex to binary?
Replace each hex digit with its four-bit group: 2F7 becomes 0010 1111 0111. No division or multiplication is needed, because one hex digit is exactly four bits.
How do you convert hex to octal?
Go through binary: expand each hex digit to four bits, regroup the bits in threes from the right (padding the left with zeros), then read each trio as an octal digit 0–7.
Why is hexadecimal used instead of decimal in computing?
Because 16 is a power of 2, hex converts to binary digit-by-digit, while decimal does not. One byte is exactly two hex digits, which makes memory contents, colours, and hashes compact and readable.
Is 0x part of the hex number?
No. 0x is a prefix that signals “what follows is hexadecimal” in code and calculators. The value of 0x2F7 is 759; the 0x contributes nothing to the value.
What is the largest value one hex digit can hold?
15, written F, which is 1111 in binary. Two hex digits hold up to 255 (FF), which is why a single byte ranges from 00 to FF.
Convert any hex value instantly
Run your own numbers instead of guessing from someone else’s example.
