Binary to Hex Converter
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.
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).
- Split the binary digits into groups of 4, starting from the right.
- Pad the leftmost group with zeros if it is short.
- Replace each group with its hexadecimal digit from the table.
- 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.
| 4 bits | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
Each base is defined by three things: which digits it uses, how a value is marked, and what each position is worth.
| Base | Radix | Digits | Prefix | Place worth | Typical range |
|---|---|---|---|---|---|
| Binary | 2 | 0, 1 | 0b | 2ⁿ | 8-bit byte 0–255 (00000000–11111111); 4-bit nibble 0–15; 16/32/64-bit words |
| Hexadecimal | 16 | 0–9, A–F (A=10 … F=15; case-insensitive) | 0x | 16ⁿ | 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".
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.
What is 0b11111111 in hexadecimal?
0b11111111 in binary is FF in hexadecimal.
Method: regroup the bits in fours; 11111111 is 11111111 in binary.
What is 0b0110 in hexadecimal?
0b0110 in binary is 6 in hexadecimal.
Method: regroup the bits in fours; 0110 is 110 in binary.
What is 0b1011 in hexadecimal?
0b1011 in binary is B in hexadecimal.
Method: regroup the bits in fours; 1011 is 1011 in binary.
What is 0b00101111 in hexadecimal?
0b00101111 in binary is 2F in hexadecimal.
Method: regroup the bits in fours; 00101111 is 101111 in binary.
What is 0b1010 in hexadecimal?
0b1010 in binary is A in hexadecimal.
Method: regroup the bits in fours; 1010 is 1010 in binary.
What is 0b1100100 in hexadecimal?
0b1100100 in binary is 64 in hexadecimal.
Method: regroup the bits in fours; 1100100 is 1100100 in binary.
What is 0b1000 in hexadecimal?
0b1000 in binary is 8 in hexadecimal.
Method: regroup the bits in fours; 1000 is 1000 in binary.
What is 0b10000 in hexadecimal?
0b10000 in binary is 10 in hexadecimal.
Method: regroup the bits in fours; 10000 is 10000 in binary.
What is 0b100000 in hexadecimal?
0b100000 in binary is 20 in hexadecimal.
Method: regroup the bits in fours; 100000 is 100000 in binary.
What is 0b1000000 in hexadecimal?
0b1000000 in binary is 40 in hexadecimal.
Method: regroup the bits in fours; 1000000 is 1000000 in binary.
What is 0b10000000 in hexadecimal?
0b10000000 in binary is 80 in hexadecimal.
Method: regroup the bits in fours; 10000000 is 10000000 in binary.
What is 0b1100 in hexadecimal?
0b1100 in binary is C in hexadecimal.
Method: regroup the bits in fours; 1100 is 1100 in binary.
What is 0b1111 in hexadecimal?
0b1111 in binary is F in hexadecimal.
Method: regroup the bits in fours; 1111 is 1111 in binary.
What is 0b10100 in hexadecimal?
0b10100 in binary is 14 in hexadecimal.
Method: regroup the bits in fours; 10100 is 10100 in binary.
What is 0b11001 in hexadecimal?
0b11001 in binary is 19 in hexadecimal.
Method: regroup the bits in fours; 11001 is 11001 in binary.
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
- Reading the remainders top to bottom. They come out in reverse, so the digits land backwards.
- Using a digit the base does not have — an 8 in octal, or a 2 in binary. The value cannot be read at all.
- Grouping bits from the left. Groups are counted from the right, and the leftmost group is the one that gets padded.
- Treating the result as a character code. 1000001 is a number here, not the letter A.
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.
Related Conversions
The rest of the family sits on every conversion in this family.