Hex to Binary
Type a hex value and see each digit turn into four bits. Prefixes like 0x and #, spaces and colons are all fine.
The converter could not load. Refresh the page to try again.
Digit by digit
Why this conversion is so easy
Sixteen is two to the power of four, so one hex digit holds exactly what four bits can hold. That means you never have to calculate anything across the whole number. You swap each digit for its four bits and move on to the next.
Decimal has no such luck. The decimal number 99 is 1100011 in binary, and nothing in that answer lines up with either 9. Hex 99 is 1001 1001, where you can see each 9 sitting in its own group.
Hex to binary chart
These sixteen rows are all you need for any hex number, however long. Select a digit to load it into the converter.
A worked example: 3AF
Take the first digit
3 is 2 + 1, so its four bits are
0011.Take the next digit
A is 10, which is 8 + 2, so it becomes
1010.Take the last digit
F is 15, the largest a single digit can go, so every bit is on:
1111.Join them up
That gives
0011 1010 1111. You can drop the two zeros at the front and write11 1010 1111, which has the same value.
You don't need to memorise the chart
The four bits are worth 8, 4, 2 and 1. To work out any digit, make its value from those four numbers. D is 13, which is 8 + 4 + 1, so it's 1101. After a while you'll start to know the common ones by sight.
A few are worth learning first. F is all ones and 0 is all zeros. 8 is 1000, the top bit alone. 5 and A are mirror images of each other, 0101 and 1010. You'll see that pair a lot in test patterns.
Going the other way
To turn binary into hex, split the bits into fours starting from the right, then replace each group with one digit. If the leftmost group comes up short, add zeros to the front.
101111 = 10 1111 = 0010 1111 = 2F
Starting from the left is the classic slip here, and it gives a completely different number.
Where you'll meet hex
Programmers use hex because it's binary in shorthand. 11011110101011011011111011101111 is hopeless to read aloud, and DEADBEEF is the same 32 bits.
#2743E8
Colours
Each pair of digits is one byte for red, green or blue. The table below shows this one taken apart.
00:1A:2B:3C:4D:5E
MAC addresses
Your network card's address is 12 hex digits, which makes 48 bits. Paste one in above and the colons are ignored.
2001:0db8::1
IPv6 addresses
A full IPv6 address has eight groups of four hex digits, 128 bits in total. The double colon stands in for a run of zeros.
0xF0
Bit masks
In binary this is 1111 0000, so code can use it to keep the top four bits of a byte and clear the bottom four.
| Channel | Hex | Binary | Decimal |
|---|---|---|---|
| Red | 27 | 0010 0111 | 39 |
| Green | 43 | 0100 0011 | 67 |
| Blue | E8 | 1110 1000 | 232 |
Where answers usually go wrong
Trimming zeros from a digit in the middle
Only zeros at the very front can go. A0F is 1010 0000 1111. Skip the middle group and you've written AF, a different number.
Using fewer than four bits
Every digit gets all four. 1 inside a longer number is 0001, not 1. Otherwise 1F would become 11111, which is correct by luck, while F1 would become 11111 too.
Reading hex 10 as ten
Hex 10 is sixteen, or 0001 0000. This is why you'll see the 0x prefix in code. It tells you which system you're looking at.
Mixing up the letters
A is 10 and F is 15, and counting along your fingers is fine. B, at 11, is 1011, and D, at 13, is 1101. Those two get swapped a lot.
Try these yourself
Work each one out on paper before you open it.
What is C4 in binary?
1100 0100. C is 12, which is 8 + 4, and 4 is just the 4 bit.
What is 7E in binary?
0111 1110. 7 is 4 + 2 + 1, and E is 14, which is 8 + 4 + 2.
What is 0x1F3 in binary?
0001 1111 0011, or 1 1111 0011 without the leading zeros. The 0x isn't part of the value, so you only convert 1, F and 3.
Common questions
What is FF in binary?
It's 1111 1111, which is 255 in decimal and the largest value one byte can hold.
What does the 0x mean?
It's a label that says "this number is hex", used in C, JavaScript, Python and many other languages. The # in colour codes does a similar job. Neither one is part of the value.
Should I keep the leading zeros?
Keep them when each digit needs to stay visible, such as with bytes, colours and masks. Drop them when you only care about the number's value. The tool shows both so you can copy either.
Does upper or lower case matter?
No. ff, FF and fF all mean the same thing.
How big a value can I enter?
Up to 4,096 hex digits, which is 16,384 bits. The digit cards show the first 64 digits, and the results above always hold the full value.
Is what I type sent anywhere?
No. The conversion runs in your browser, so it never reaches our server. A link you copy from the address bar can contain the value, so keep that in mind when you share it.