Binary to Hex Converter

0×2⁷128=0
0×2⁶64=0
1×2⁵32=32
0×2⁴16=0
1×8=8
1×4=4
1×2=2
1×2⁰1=1
total=47

Show the working for hex → binary

Going the other way? Convert hex back to binary

How do you convert binary to hex?

Binary to hex conversion works in groups of 4 bits, because one hexadecimal digit is worth exactly 4 bits, so no arithmetic is needed.

In short

Binary 11111111 is hex FF. Group the bits in fours from the right, pad the leftmost group with zeros, and convert each group to one hex digit (1111 = F).

  1. Split the binary digits into groups of 4, starting from the right.
  2. Pad the leftmost group with zeros if it is short.
  3. Replace each group with its hexadecimal digit from the table.
  4. Join the digits in order: 00101111 = 2F.

Binary to Hexadecimal Conversion Table

One hexadecimal digit equals exactly 4 bits (16 = 2⁴); one octal digit equals exactly 3 bits (8 = 2³). Hex and octal are therefore converted by grouping bits, and hex ↔ octal passes through binary. That is the whole method, so the table below is the only thing you need: every group of 4 bits has exactly one hex digit, and the mapping never changes. Binary writes values on the digit set 0, 1 with each place worth 2ⁿ, and a value marked 0b is binary; hex values are marked 0x.

Binary to Hexadecimal Conversion Table
4 bitsHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15

Each base is defined by three things: which digits it uses, how a value is marked, and what each position is worth.

Base reference
BaseRadixDigits PrefixPlace worthTypical range
Binary20, 1 0b2ⁿ8-bit byte 0–255 (00000000–11111111); 4-bit nibble 0–15; 16/32/64-bit words
Hexadecimal160–9, A–F (A=10 … F=15; case-insensitive) 0x16ⁿ2 digits cover a byte (00–FF); 6 digits = RGB colour; 8 digits = 32-bit word

Worked Example: 00101111 to Hexadecimal

One value, converted the long way so the working is visible. This is the same grid the converter shows when you turn on "show steps".

0×2⁷128=0
0×2⁶64=0
1×2⁵32=32
0×2⁴16=0
1×8=8
1×4=4
1×2=2
1×2⁰1=1
total=47

Result: 00101111 = 2F

Both bases here are powers of two, so no division is needed. One hexadecimal digit is worth exactly 4 bits, which means the conversion is a regrouping of the same bits rather than a change of value.

Written out, 00101111 is 101111 in binary. Regrouping those bits into 4s from the right, and padding the leftmost group with zeros if it is short, gives 2F. Counting the groups from the left instead is where this goes wrong: the padding then lands on the wrong end and every digit shifts.

Check it in reverse

The value returns unchanged. Convert 2F back and you get 101111, because a base change rewrites the digits without touching the quantity they stand for. That is the whole test: if the round trip differs, a digit was misread. To check it by hand, convert the binary result back to hex and compare it with the number you started from.

Worked examples: binary to hex

Each example gives the value first, then the working. Click a value to load it in the converter.

What is 0b0000 in hexadecimal?

0b0000 in binary is 0 in hexadecimal.

Method: regroup the bits in fours; 0000 is 0 in binary.

Load this value in the converter

What is 0b11111111 in hexadecimal?

0b11111111 in binary is FF in hexadecimal.

Method: regroup the bits in fours; 11111111 is 11111111 in binary.

Load this value in the converter

What is 0b0110 in hexadecimal?

0b0110 in binary is 6 in hexadecimal.

Method: regroup the bits in fours; 0110 is 110 in binary.

Load this value in the converter

What is 0b1011 in hexadecimal?

0b1011 in binary is B in hexadecimal.

Method: regroup the bits in fours; 1011 is 1011 in binary.

Load this value in the converter

What is 0b00101111 in hexadecimal?

0b00101111 in binary is 2F in hexadecimal.

Method: regroup the bits in fours; 00101111 is 101111 in binary.

Load this value in the converter

What is 0b1010 in hexadecimal?

0b1010 in binary is A in hexadecimal.

Method: regroup the bits in fours; 1010 is 1010 in binary.

Load this value in the converter

What is 0b1100100 in hexadecimal?

0b1100100 in binary is 64 in hexadecimal.

Method: regroup the bits in fours; 1100100 is 1100100 in binary.

Load this value in the converter

What is 0b1000 in hexadecimal?

0b1000 in binary is 8 in hexadecimal.

Method: regroup the bits in fours; 1000 is 1000 in binary.

Load this value in the converter

What is 0b10000 in hexadecimal?

0b10000 in binary is 10 in hexadecimal.

Method: regroup the bits in fours; 10000 is 10000 in binary.

Load this value in the converter

What is 0b100000 in hexadecimal?

0b100000 in binary is 20 in hexadecimal.

Method: regroup the bits in fours; 100000 is 100000 in binary.

Load this value in the converter

What is 0b1000000 in hexadecimal?

0b1000000 in binary is 40 in hexadecimal.

Method: regroup the bits in fours; 1000000 is 1000000 in binary.

Load this value in the converter

What is 0b10000000 in hexadecimal?

0b10000000 in binary is 80 in hexadecimal.

Method: regroup the bits in fours; 10000000 is 10000000 in binary.

Load this value in the converter

What is 0b1100 in hexadecimal?

0b1100 in binary is C in hexadecimal.

Method: regroup the bits in fours; 1100 is 1100 in binary.

Load this value in the converter

What is 0b1111 in hexadecimal?

0b1111 in binary is F in hexadecimal.

Method: regroup the bits in fours; 1111 is 1111 in binary.

Load this value in the converter

What is 0b10100 in hexadecimal?

0b10100 in binary is 14 in hexadecimal.

Method: regroup the bits in fours; 10100 is 10100 in binary.

Load this value in the converter

What is 0b11001 in hexadecimal?

0b11001 in binary is 19 in hexadecimal.

Method: regroup the bits in fours; 11001 is 11001 in binary.

Load this value in the converter

Every example above reverses exactly — expand the same hex digits into bits.

What About Padding, Fractions and Width?

Leading zeros and width

A number carries no leading zeros unless a width is fixed. 2F and 02F are the same value, so the converter writes the short form. Fixed widths belong to bytes and registers, not to arithmetic. what a base is and why position matters covers where width does matter.

Fractions and the point

Digits after a point convert by the same rule with negative powers, so the first place after the point is worth 1/16. Many fractions that end neatly in decimal repeat forever in binary, which is where rounding creeps in.

Negative values

A minus sign is kept in front of the digits. Fixed-width binary encodes sign differently, using two's complement, and that is a separate rule from the base change itself.

How large a value can be

The method has no ceiling; each extra binary digit multiplies the range by 2. Practical limits come from the width a machine stores the value in, not from the conversion.

Binary to Hex in Code

The same rule in one line. Both group the bits and return the hexadecimal digits.

Python: format(int('00101111', 2), 'X')
JavaScript: parseInt('00101111', 2).toString(16).toUpperCase()

Common Mistakes

Frequently Asked Questions

What is the binary to hex table?

It is the sixteen-row map from each 4-bit group to one hex digit (0–9, A–F): 0000 = 0, 0001 = 1, 0010 = 2, 0011 = 3, 0100 = 4, 0101 = 5, 0110 = 6, 0111 = 7, 1000 = 8, 1001 = 9, 1010 = A, 1011 = B, 1100 = C, 1101 = D, 1110 = E, 1111 = F.

What if the number of bits is not a multiple of four?

Pad the leftmost group with zeros until it holds four bits — one nibble. A byte is 8 bits and holds 256 values, 0–255; a nibble is 4 bits. So 101111 pads to 0010 1111 and reads 2F.

Why does one hex digit equal four bits?

Because four bits count 0 to 15, and hexadecimal has exactly sixteen digits. One hexadecimal digit equals exactly 4 bits (16 = 2⁴); one octal digit equals exactly 3 bits (8 = 2³). Hex and octal are therefore converted by grouping bits, and hex ↔ octal passes through binary.

How do you convert binary to hex in Python?

Read the digits as base 2, then format the number as hex — the one-liner under Binary to Hex in Code. It converts the bit pattern, never its sign. 11111111 is 255 as an unsigned 8-bit number (0xFF, 0o377). Read as 8-bit two's complement it is −1; the 8-bit signed range is −128 to 127.

Regrouping loses nothing, so the same value converts straight back in the hex to binary direction.

The rest of the family sits on every conversion in this family.