Binary to hex converter
Type binary to get hexadecimal. Every four bits become one hex digit.
Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.
How to convert binary to hex
Split the bits into groups of four, starting from the right, and pad the leftmost group with zeros if it’s short. Each group of four (a nibble) is exactly one hex digit, so swap each group using the table below.
1101 0110 → D 6 → D6. No division needed, because 16 is 24.
Binary to hex chart
| Binary | Hex | Binary | Hex |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0001 | 1 | 1001 | 9 |
| 0010 | 2 | 1010 | A |
| 0011 | 3 | 1011 | B |
| 0100 | 4 | 1100 | C |
| 0101 | 5 | 1101 | D |
| 0110 | 6 | 1110 | E |
| 0111 | 7 | 1111 | F |
Common mistakes
Grouping from the left
101011 grouped as 1010 11 gives A3, which is wrong
Instead: Group from the right: 10 1011, padded to 0010 1011, gives 2B
Writing 10 to 15 as two digits
Writing 1100 as 12 instead of C
Instead: Each group is one hex digit: 10 to 15 are A to F
Mixing up B and D
1011 is B (11) and 1101 is D (13)
Instead: Add the place values 8, 4, 2, 1 rather than guessing from the shape
Where binary turns into hex
Programmers write bit patterns in hex because it’s four times shorter. A web colour is the clearest example: in CSS, #FF8000 is three bytes, red, green and blue. In binary that’s 11111111 10000000 00000000, and grouping it by four gives FF 80 00 again.
Sources and method
- W3C CSS Color Module Level 3 (Recommendation, 18 January 2022), section 4.2.1: RGB colour values in #rrggbb hexadecimal notation. Checked 2026-11-25.
Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.
Questions
What is a nibble?
Four bits, half a byte. One nibble is one hex digit, so a byte is always exactly two hex digits.
What if the number of bits isn't a multiple of 4?
Add zeros on the left. 101 becomes 0101, which is 5 in hex. Leading zeros don’t change the value.
How do I convert binary to octal instead?
Group the bits in threes, because 8 is 23. The base converter on this site does both.