How to convert hex to binary
- Paste hex into Input, one number per line. A 0x prefix is fine.
- Each line becomes binary as you type.
- Tick Group binary digits in 4s so each hex digit lines up with one block of four bits.
Converting hex to binary by hand
Replace each hex digit with its four bits and join them up. Every digit except the first needs all four bits, leading zeros included, or the bits after it end up in the wrong places. For 3C:
- 3 is 0011.
- C is 12, which is 1100.
- Joined: 0011 1100, or 111100 without the leading zeros.
That’s 60 in decimal. The digit-by-digit swap works because 16 is 2 to the 4th power, so no arithmetic across digits is needed.
Common hex masks in binary
| Hex | Binary | What it selects |
|---|---|---|
| 0F | 0000 1111 | Low four bits of a byte |
| F0 | 1111 0000 | High four bits of a byte |
| 80 | 1000 0000 | Top bit, the sign bit in a signed byte |
| 7F | 0111 1111 | Every bit except the top one |
| 55 | 0101 0101 | Every other bit, starting at bit 0 |
| AA | 1010 1010 | Every other bit, starting at bit 1 |
| FF | 1111 1111 | All eight bits |
A mask is combined with AND to keep some bits and clear the rest. For example, x AND 0F keeps the low four bits of x and sets the others to 0.