How to convert binary to hex
- Paste or type a binary number such as
1101 0110or0b11010110. Put several numbers on separate lines to convert them all at once. - The hex value appears as you type, together with decimal and octal. The steps below the result show how the bits are grouped.
- Copy the hex result, or press Swap to convert hex back to binary.
How to convert binary to hexadecimal
- Split the binary number into groups of 4 bits, starting from the right (for fractions, start at the binary point and work outwards).
- Pad the leftmost group with zeros if it has fewer than 4 bits.
- Replace every group with its hex digit from the table below.
Example: 1011111001 → 0010 1111 1001 → 2, F, 9 → 2F9. Bytes are even quicker: 1100 0011 = C3.
Binary to hex table
| 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 |
Why programmers write binary as hex
Long binary numbers are hard to read and easy to mistype. Because one hex digit stands for exactly four bits, hex is four times shorter but still shows the bit pattern directly: the 32-bit value 1101 1110 1010 1101 1011 1110 1110 1111 is simply DEADBEEF. That is why memory addresses, colour codes, MAC addresses, file signatures and machine code are written in hex.
Frequently asked questions
What if the number of bits is not a multiple of 4?
Add zeros on the left until it is. 101 becomes 0101 = 5 and 11010 becomes 0001 1010 = 1A. Leading zeros never change the value.
What is 11111111 in hex?
11111111 is FF in hex: the two groups 1111 and 1111 are both F. In decimal it is 255.
How do I convert binary to hex in Python, JavaScript or Excel?
Python: format(int('11010110', 2), 'X') returns D6. JavaScript: parseInt('11010110', 2).toString(16) returns d6. Excel: =BIN2HEX("11010110"), but Excel accepts at most 10 bits.
Can I convert binary fractions to hex?
Yes. Group the bits after the point from left to right and pad the last group with zeros on the right: 0.1011 = 0.B and 110.01 = 6.4 in hex.