Menu

Hex to Binary Converter

Type a hexadecimal number and read its binary form, with each digit's four bits shown underneath. It opens on 3F, which is 111111.

By Nethanel Bar, Co-founder & CEO

Last updated

Ready to actually learn to code?

Coddy teaches you by writing real code in your browser - interactive lessons, instant feedback, and AI help when you get stuck.

How to convert hex to binary

Hex and binary line up exactly: one hex digit always stands for four bits, because 16 is 2 to the power 4. So there is no arithmetic to do. Look up each digit's four bits and write them side by side.

The sixteen patterns are all there is to learn. 0 is 0000, 1 is 0001, 8 is 1000, A is 1010 and F is 1111; the table below lists every one.

Leading zeros in the first group can be dropped, since 0011 1111 and 111111 are the same number. Keep them when the value fills a fixed width such as a byte.

What to know about hex and binary

  • One hex digit is always four bits, and two hex digits are one byte.
  • The patterns for 8, 4, 2 and 1 are 1000, 0100, 0010 and 0001; every other digit combines them.
  • F is 1111 and 0 is 0000, so FF is a byte with every bit set.
  • Going back uses the same table in reverse: group the bits in fours from the right and look each group up.

Hex to binary table

All sixteen hex digits with their 4-bit patterns and decimal values.

HexBinaryDecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115

Hex to binary, worked out

3F

Hex

3F

Binary

0011 1111

3 is 0011 and F is 1111.

A byte mask

Hex

0xF0

Binary

1111 0000

The high four bits are set and the low four are clear, which is how a mask selects half a byte.

A color

Hex

#FF8800

Binary

11111111 10001000 00000000

Each pair of hex digits becomes one byte of eight bits.

CAFE

Hex

CAFE

Binary

1100 1010 1111 1110

C is 1100, A is 1010, F is 1111 and E is 1110.

Common hex to binary mistakes

  • Writing a digit with fewer than four bits in the middle of a number. Inside A5B, the 5 is 0101, not 101.
  • Treating a letter as two digits. A is one digit with the value 10, and its bits are 1010.
  • Converting through decimal first. It works, but it is slower and easier to get wrong than the lookup.
  • Putting the groups in the wrong order. The first hex digit gives the leftmost four bits.

Hex to binary FAQ

What is F in binary?
1111. F is 15, and 15 is 8 + 4 + 2 + 1.
What is A in binary?
1010. A is 10, and 10 is 8 + 2.
Why is one hex digit four bits?
Because 16 is 2 × 2 × 2 × 2. Four bits have exactly 16 combinations, the same as the 16 hex digits.
How do I convert hex to binary in Python?
bin(int('3F', 16)) returns '0b111111'. To keep all eight bits, use format(int('3F', 16), '08b'), which returns '00111111'.

Learn more

Other developer tools

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED