Hex to Binary Converter
Going the other way? Convert binary back to hex →
How do you convert hex to binary?
Hex to binary conversion works in groups of 4 bits, because one hexadecimal digit is worth exactly 4 bits, so no arithmetic is needed.
Hex 2F is binary 00101111. Replace each hex digit with its 4-bit value (2 = 0010, F = 1111) and join the groups in order; the leading zeros can be dropped for a plain number.
- Take the first hexadecimal digit.
- Write it as 4 binary digits from the table.
- Repeat for every digit, keeping the order.
- Join the groups and drop any leading zeros: 2F = 101111.
Hexadecimal to Binary 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 |
|---|---|---|---|---|---|
| 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 |
| Binary | 2 | 0, 1 | 0b | 2ⁿ | 8-bit byte 0–255 (00000000–11111111); 4-bit nibble 0–15; 16/32/64-bit words |
Worked Example: 2F to Binary
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: 2F = 101111
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, 2F is 101111 in binary. Regrouping those bits into 4s from the right, and padding the leftmost group with zeros if it is short, gives 101111. 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 101111 back and you get 2F, 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 hex value back to binary and compare it with the number you started from.
Worked examples: hex to binary
Each example gives the value first, then the working. Click a value to load it in the converter.
What is 0xE in binary?
0xE in hexadecimal is 1110 in binary.
Method: regroup the bits in fours; E is 1110 in binary.
What is 0x2F in binary?
0x2F in hexadecimal is 101111 in binary, or 00101111 with the leading zeros kept.
Method: regroup the bits in fours; 2F is 101111 in binary.
What is 0xFF in binary?
0xFF in hexadecimal is 11111111 in binary.
Method: regroup the bits in fours; FF is 11111111 in binary.
What is 0xA in binary?
0xA in hexadecimal is 1010 in binary.
Method: regroup the bits in fours; A is 1010 in binary.
What is 0x64 in binary?
0x64 in hexadecimal is 1100100 in binary, or 01100100 with the leading zeros kept.
Method: regroup the bits in fours; 64 is 1100100 in binary.
What is 0x8 in binary?
0x8 in hexadecimal is 1000 in binary.
Method: regroup the bits in fours; 8 is 1000 in binary.
What is 0x10 in binary?
0x10 in hexadecimal is 10000 in binary, or 00010000 with the leading zeros kept.
Method: regroup the bits in fours; 10 is 10000 in binary.
What is 0x20 in binary?
0x20 in hexadecimal is 100000 in binary, or 00100000 with the leading zeros kept.
Method: regroup the bits in fours; 20 is 100000 in binary.
What is 0x40 in binary?
0x40 in hexadecimal is 1000000 in binary, or 01000000 with the leading zeros kept.
Method: regroup the bits in fours; 40 is 1000000 in binary.
What is 0x80 in binary?
0x80 in hexadecimal is 10000000 in binary.
Method: regroup the bits in fours; 80 is 10000000 in binary.
What is 0xC in binary?
0xC in hexadecimal is 1100 in binary.
Method: regroup the bits in fours; C is 1100 in binary.
What is 0xF in binary?
0xF in hexadecimal is 1111 in binary.
Method: regroup the bits in fours; F is 1111 in binary.
What is 0x14 in binary?
0x14 in hexadecimal is 10100 in binary, or 00010100 with the leading zeros kept.
Method: regroup the bits in fours; 14 is 10100 in binary.
What is 0x19 in binary?
0x19 in hexadecimal is 11001 in binary, or 00011001 with the leading zeros kept.
Method: regroup the bits in fours; 19 is 11001 in binary.
What is 0x32 in binary?
0x32 in hexadecimal is 110010 in binary, or 00110010 with the leading zeros kept.
Method: regroup the bits in fours; 32 is 110010 in binary.
What is 0xC8 in binary?
0xC8 in hexadecimal is 11001000 in binary.
Method: regroup the bits in fours; C8 is 11001000 in binary.
Every example above reverses exactly — regroup the same bits into hex digits.
What About Padding, Fractions and Width?
Leading zeros and width
A number carries no leading zeros unless a width is fixed. 101111 and 0101111 are the same value, so the converter writes the short form. Fixed widths belong to bytes and registers, not to arithmetic. repeated division and positional expansion 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/2. 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 hexadecimal digit multiplies the range by 16. Practical limits come from the width a machine stores the value in, not from the conversion.
Hex to Binary in Code
The same rule in one line. Both group the bits and return the binary digits.
Python: format(int('2F', 16), 'b') JavaScript: parseInt('2F', 16).toString(2) 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. 41 is a number here, not the letter A.
Frequently Asked Questions
Do you keep leading zeros when converting hex to binary?
Keep them inside the number and drop them at the front: 2F is 0010 1111, printed as 101111. Width only matters once a value is signed. 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.
Why does the converter reject letters after F?
Because base 16 stops at F. The digit set is 0–9, A–F (A=10 … F=15; case-insensitive), so a G carries no place value and the input cannot be read as a number.
Can you convert a hex fraction like 1.8 to binary?
Yes. Expand the digits on both sides of the point: 1 becomes 0001 and 8 becomes 1000, so 1.8 is 1.1000, or 1.1 once the trailing zeros go. Hex fractions always terminate, because 16 is a power of two.
What is a nibble?
Four bits, one hex digit. A byte is 8 bits and holds 256 values, 0–255; a nibble is 4 bits. 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.
Expanding and regrouping are the same move, so the same value converts straight back in the binary to hex direction.
Related Conversions
The rest of the family sits on binary, octal, decimal and hex converters.