Binary to hex converter
Convert binary numbers to hex — every 4 bits become one hex digit. Exact at any size, with a worked example and a table of common values. Free, and computed in your browser.
Part of developer tools.
Binary
10101101
Octal
255
Decimal
173
Hexadecimal
AD
Binary to hex table
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 100 | 1100100 | 64 |
| 127 | 1111111 | 7F |
| 255 | 11111111 | FF |
| 256 | 100000000 | 100 |
| 1000 | 1111101000 | 3E8 |
| 1024 | 10000000000 | 400 |
| 4096 | 1000000000000 | 1000 |
| 65535 | 1111111111111111 | FFFF |
| 4294967295 | 11111111111111111111111111111111 | FFFFFFFF |
| 18446744073709551615 | 1111111111111111111111111111111111111111111111111111111111111111 | FFFFFFFFFFFFFFFF |
The last rows are the largest 32-bit and 64-bit unsigned values. The second is past the point where ordinary JavaScript numbers start rounding; the table and the converter above both compute with BigInt, so every digit is exact.
How to convert binary to hex
Split the binary number into groups of 4 bits, starting from the right, and pad the leftmost group with zeros if it comes up short. Each group is exactly one hex digit, because 16 = 2⁴: no carrying and no arithmetic across groups, just a lookup of 16 possible patterns. For 10101101: 1010 1101; then 1010 → A, 1101 → D — so 10101101 in binary is AD in hex.
Binary and hex side by side
The largest 16-bit value is 1111111111111111 in binary and FFFF in hex: 16 digits against 4. Every hex digit is exactly 4 bits, so the lengths stay in a fixed ratio and any stretch of digits can be converted without looking at its neighbours. Hex is the usual way to write bytes — colours like #FF8800, memory addresses, hashes, escape sequences — because a byte is always exactly two hex digits. In JavaScript and Python source, 173 is written 0b10101101 in binary and 0xAD in hex. Paste a prefixed number into the converter and it switches to the matching base; a number with no prefix is read in the selected base — binary on this page.
Other conversions
Going the other way? Hex to binary converter.
Or open the full number base converter and see a number in all four bases at once.