Binary to hex converter

To convert binary to hex, split the bits into groups of four from the right and replace each group with one hex digit. So 1101 is D and 11111111 is FF. Paste a binary number below to get its exact hex value, however many bits it has. The converter runs in your browser.

Input number

Enter a whole number and choose the bases.

Enter a whole number, choose the bases, then convert.

Allowed digits depend on your input base.

Swap uses the result as your next input when one is available.

Whole numbers only. Enter digits without prefixes or separators: FF, not 0xFF. Surrounding whitespace is ignored.

Converted number

The same integer in your chosen base.

Exact whole-number conversion

Binary to hex conversion table

Each hex digit in the table is the converter's result for the group on its left. The groups were typed with their leading zeros.
4-bit groupHex digit
00000
00011
00102
00113
01004
01015
01106
01117
10008
10019
1010A
1011B
1100C
1101D
1110E
1111F

These sixteen groups are every pattern that four bits can form, and each maps to exactly one hex digit. That one-to-one match is the whole method. Learn the groups for A to F, 1010 to 1111, and the others follow from ordinary counting.

A group whose first bit is 1 gives a digit from 8 to F. A group that starts with 0 gives 0 to 7. So a byte that starts with 1, such as 10000000, always has a first hex digit of 8 or more, here 80.

How to convert binary to hex

Start at the right end of the bit string and mark off groups of four. If the leftmost group is short, add zeros on its left until it has four bits. Then swap each group for its hex digit from the table, keeping the order.

Take 110101. From the right, the groups are 0101 and 11, and the short group becomes 0011. That gives the digits 3 and 5, so 110101 is 35 in hex. For 101111000011, the groups 1011, 1100 and 0011 give B, C and 3, which is BC3.

Always group from the right. Grouping 110101 from the left would give 1101 and 01, a different and wrong answer. The converter avoids the question: it reads the full value of the bits and writes that value in base 16, so its answer matches correct right-to-left grouping every time.

Using the binary to hex converter

The page opens with Binary (2) in From base and Hexadecimal (16) in To base. Paste the bits in the Number field and select Convert number. The hex digits appear in uppercase in the Converted number panel, where Copy result copies them and Download TXT saves them.

Leading zeros in the input are fine, so 0110 gives 6 and 00110101 gives 35. Remove any spaces between groups before you convert: 0110 0110 is rejected as an invalid format, while 01100110 gives 66. A 0b prefix is rejected too, because b is not a binary digit.

The result has no leading zeros and no 0x prefix. Add them if your code expects a fixed number of hex digits. Swap bases moves the hex into the Number field and turns the form into hex to binary, so you can check the bits. Reset returns the form to binary to hex.

Questions

How do I convert binary to hexadecimal?

Split the bits into groups of four, starting from the right, and pad the leftmost group with zeros. Replace each group with its hex digit: 0000 is 0, 1001 is 9, 1010 is A and 1111 is F. For 10000000 the groups 1000 and 0000 give 80.

What is 01100110 in hexadecimal?

01100110 in binary is 66 in hexadecimal. The two groups are 0110 and 0110, and each is the hex digit 6. The same byte is 102 in decimal. Paste it here as one run of eight bits, with no space between the groups, and select Convert number.

What is 11111111 in hexadecimal?

11111111 in binary is FF in hexadecimal and 255 in decimal. Both groups are 1111, the digit F. It is the largest value of one byte. Sixteen 1s give FFFF, so each group of four 1s adds one F to the hex result.

What is binary 1101 in hex?

Binary 1101 is D in hex, which is 13 in decimal: 8 + 4 + 1. It is already one group of four bits, so it maps straight to a single hex digit. Its neighbours are 1100, which is C, and 1110, which is E.