A hex to binary converter expands hexadecimal numbers into the binary digits they represent. Because each hex digit stands for exactly four bits, the conversion is quick to do by hand once you know the pattern, and this tool shows every digit next to its bits. Here's how hexadecimal works, how to convert hex to binary without a calculator, and where you'll run into hex in practice.
What hexadecimal is
Hexadecimal, or hex, is base 16. It needs sixteen digit symbols, so after 0 to 9 it borrows the letters A to F, which stand for the values 10 to 15. Each position in a hex number is worth sixteen times the one to its right: 1, 16, 256, 4,096 and so on. So 2F means 2 × 16 + 15 = 47. Hex isn't used because people like counting in sixteens. It's used because it lines up perfectly with binary.
Why every hex digit is four bits
Sixteen is 2⁴, so four bits can hold exactly sixteen different values, from 0000 to 1111. That means every hex digit corresponds to one group of four bits, sometimes called a nibble, with no overlap and nothing left over. To convert hex to binary, you never need to do any arithmetic on the whole number. You replace each digit with its four bits and write them side by side. The table further down this page lists all sixteen patterns.
Converting hex to binary by hand
Take DEADBEEF, a value programmers often use as a recognizable marker in memory. Look up each digit: D is 1101, E is 1110, A is 1010, D is 1101, B is 1011, E is 1110, E is 1110 and F is 1111. Written together, that's 1101 1110 1010 1101 1011 1110 1110 1111, a 32-bit binary number. Converting through decimal first would give the same answer, but it's much slower and easier to get wrong.
Bytes, words and leading zeros
Two hex digits make one byte, so FF is 1111 1111, or 255, the largest value a byte can hold. Eight hex digits make a 32-bit word and sixteen make a 64-bit value. When hex is used to describe bytes, leading zeros matter: 0F is the byte 0000 1111, and keeping all eight bits shows how it's stored. When you only care about the value, the leading zeros can go, and 1111 means the same number. This hex to binary converter keeps the full four bits per digit by default, and the Drop leading zeros switch removes them.
Where you'll see hexadecimal
- Colors. CSS colors such as
#FF8000are three bytes, for red, green and blue. In binary that's1111 1111 1000 0000 0000 0000. - Memory addresses and dumps. Debuggers and hex editors show memory and file contents in hex, two digits per byte.
- Hashes and keys. A SHA-256 hash is 256 bits, usually written as 64 hex digits.
- Network addresses. MAC addresses are 12 hex digits, and IPv6 addresses are 128 bits written as 32 hex digits.
- Unicode. Character code points are written in hex, so
U+0041is the letter A.
Hex notation in code
Different languages and tools mark hex numbers in different ways. C, C++, Java, JavaScript, Python and most modern languages use a 0x prefix, as in 0xFF. CSS uses # for colors, and some assemblers use an h suffix, as in FFh. This converter accepts a 0x prefix and ignores spaces and underscores. For colors, leave out the #, and for MAC addresses, remove the colons first.
Hex to binary quick reference
The letters are the digits people most often need to look up. These four are worth memorizing: A is 1010 (10), C is 1100 (12), E is 1110 (14) and F is 1111 (15). From those you can find the others, because B, D and F are always one more than A, C and E: just change the last bit to 1.
Tips for converting hex to binary
- Hex isn't case-sensitive.
ffandFFgive the same result. - Turn off Space between groups for one continuous binary string, ready to paste into code.
- To go the other way, use the binary to hex converter. For the decimal value, try the binary to decimal converter.
- Working with base 8 instead? The octal to binary converter works the same way with three bits per digit.
Learn the 16 four-bit patterns once and you won't need a calculator for this. Every hex value, however long, is just those patterns written side by side.