Binary to hex converter

Paste binary and read it back in hexadecimal: 11010110 becomes D6 and 11111111 becomes FF. Pick uppercase, lowercase or a 0x prefix, and open "Show the working" to see each group of four bits matched to its hex digit.

Hex to binary

Show the working
One number per line, or separate them with spaces.0 numbers
Reviewed bySam Siewert
Last updated · How we test

Runs in your browser. Nothing you type is uploaded.

How to use the converter

  1. Type or paste binary numbers, one per line or separated by spaces.
  2. Choose how the hex should look in the Output menu.
  3. Copy, download or share the result.

Width and Signed. Set Width to 8, 16, 32 or 64 bits to pad the hex to a fixed size, so 101101 at 16 bits becomes 002D. Tick Signed if the binary is a two's complement value; the hex digits stay the same, and the decimal shown under the boxes becomes the signed value. That row also gives octal, with a click to copy. Open file loads a .txt or .csv list of binary numbers.

A 0b prefix and underscores in the input are ignored, so 0b1101_0110 works. Each space-separated group is treated as its own number. If you have one long binary string with spaces every 8 bits and want it read as one value, remove the spaces first.

The binary to hex converter with Width set to 8-bit and Signed ticked. The inputs 11111111, 10000000 and 01111111 give FF, 80 and 7F, and the line under the boxes shows octal 377 and decimal -1 for the first number.
Width on 8-bit with Signed ticked. The hex digits stay FF, 80 and 7F, and only the decimal line changes: 11111111 reads as -1.

What the converter does with different binary

Each input below was typed into the converter on this page, with Output on Uppercase and Width on Auto unless the row says otherwise.

InputWhat you get
100111100 (9 bits, so the first group is padded)13C, decimal 316
0b1101_0110 (prefix and underscore)D6
1101 0110 (the same bits with a space)D 6, two separate numbers. Remove the space to get D6.
111011.111 (a binary point)3B.E, decimal 59.875
0.101 (a short fraction)0.A, padded on the right to 1010
-101101 (minus sign)-2D
00000000 (all zeros)0. With Width on 8-bit it shows 00.
10110101 with Output set to Lowercaseb5
10110101 with Output set to 0x prefix0xB5
64 ones, a full 64-bit valueFFFFFFFFFFFFFFFF, every digit kept, decimal 18446744073709551615
100000000 with Width 8-bitNo result. The message says it does not fit in 8 bits and that the largest 8-bit value is 11111111.
1012 (a digit that is not 0 or 1)No result. The message names the 2, and Show me jumps to it.
The binary to hex converter with four inputs on separate lines: 100111100, 0b1101_0110, 111011.111 and -101101. The hex column reads 13C, D6, 3B.E and -2D.
Four inputs in one list: a 9-bit number, a prefixed value with an underscore, a fraction and a negative number.

How to convert binary to hexadecimal

Hex is base 16, and 16 is 24, so every hex digit stands for exactly four bits. That turns the conversion into a lookup rather than a calculation:

  1. Split the binary into groups of four, starting from the right.
  2. If the leftmost group is short, pad it with zeros on the left.
  3. Replace each group with its hex digit. The bits in a group are worth 8, 4, 2 and 1, so 1101 is 8 + 4 + 1 = 13, which is D.
Binary 101101 split into the groups 0010 and 1101 from the right, with two padding zeros added on the left. The groups become the hex digits 2 and D, so the answer is 2D.

Take 101101. From the right, the groups are 1101 and 10. Pad the short one to 0010. 0010 is 2 and 1101 is D, so the answer is 2D. As a check, 2 × 16 + 13 = 45, and the binary to decimal converter gives 45 for 101101 too.

Grouping from the left instead of the right is the usual slip. It splits 101101 into 1011 and 01, which gives B4 if you pad the end, a completely different number.

Binary to hex table

These sixteen patterns are all you need. A group of four bits is called a nibble, half a byte, and a full byte is always two hex digits, from 00 to FF.

Chart of all sixteen 4-bit binary patterns from 0000 to 1111 with their hex digits 0 to 9 and A to F and decimal values 0 to 15.
BinaryHexDecimalBinaryHexDecimal
000000100088
000111100199
0010221010A10
0011331011B11
0100441100C12
0101551101D13
0110661110E14
0111771111F15

Worked examples

BinaryGroups of fourHexDecimal
11011101D13
010000000100 00004064
11011000110 11006C108
100011101000 11108E142
101101011011 0101B5181
111111111111 1111FF255
1001111000001 0011 110013C316
1100101110001 1001 0111197407

Notice that 110010111 becomes 197 in hex. Hex results can be made of digits only, which is why a 0x prefix is useful in code: 0x197 is 407, while plain 197 would be read as decimal.

The binary to hex converter with Show the working open for 100111100. The working groups the bits as 0001, 0011 and 1100, gives the hex digits 1, 3 and C, and the result 13C. The line above shows octal 474 and decimal 316.
100111100 with the working open. The nine bits become three groups of four once the first group is padded with three zeros.

Why programmers write binary as hex

A 32-bit value written in binary is 32 characters long and easy to misread. In hex it is eight characters, and you can still see every bit because each digit maps to a fixed group of four, so hex to binary gets you the original bits back exactly.

The 32-bit binary value 11000000101010000000000100000001 split into eight nibbles that read C0A80101 in hex, which is the IP address 192.168.1.1.

That is why memory addresses, color codes like #FF8800, MAC addresses, file signatures and network packets are all shown in hex. When those bytes are character codes, hex to text turns them back into readable words. The Wikipedia page on hexadecimal covers the notation used in different languages, such as 0x in C and JavaScript and &H in Visual Basic.

Binary fractions in hex

After the binary point, group from the point towards the right and pad on the right. 111011.111 splits into 0011 1011 before the point and 1110 after it, which gives 3B.E. Likewise 0.1011 is 0.B, and 0.101 is padded to 0.1010, which is 0.A.

Binary to hex in code

Python: hex(int('101101', 2)) returns '0x2d' (the built-in hex() function always writes lowercase with a 0x prefix), and format(int('101101', 2), 'X') returns '2D'. JavaScript: parseInt('101101', 2).toString(16) returns "2d"; for more than 53 bits use BigInt('0b' + bits).toString(16).

Frequently asked questions

What is 11111111 in hexadecimal?

FF. Each 1111 nibble is F, and FF is 255 in decimal.

What is binary 1101 in hex?

D. 1101 is 8 + 4 + 1 = 13, and 13 is written D in hex.

What is 01000000 in hex?

40. The groups are 0100 (4) and 0000 (0). It is 64 in decimal, and the ASCII code for the @ sign.

Is hex the same as binary?

No, but they describe the same values. Binary uses two digits and hex uses sixteen, so one hex digit replaces four binary digits. FF and 11111111 are the same number written two ways.

Should hex be uppercase or lowercase?

Either is correct and they mean the same value. Uppercase is common in documentation and lowercase in code and CSS. Pick whichever matches where you will paste it.

What is 01100110 in hex?

66. The groups are 0110 and 0110, and each is 6. As a byte it is 102 in decimal, which is the letter f in ASCII.

Scroll to Top