How to convert hex to binary
Write each hex digit as four bits and put the groups together in the same order. The four bits stand for 8, 4, 2 and 1, and the letters A to F stand for 10 to 15.
You never have to work out the whole number in decimal, so the conversion is just as easy for a 64-digit hash as for a single byte. The working table under the converter shows the value and the four bits for every digit you type.
Hex to binary table
| Hex | Binary | Decimal | Hex | Binary | Decimal |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | A | 1010 | 10 |
| 3 | 0011 | 3 | B | 1011 | 11 |
| 4 | 0100 | 4 | C | 1100 | 12 |
| 5 | 0101 | 5 | D | 1101 | 13 |
| 6 | 0110 | 6 | E | 1110 | 14 |
| 7 | 0111 | 7 | F | 1111 | 15 |
Leading zeros: keep or trim
Every hex digit gives four bits, so 0F gives 00001111 and 1 gives 0001. Keep the zeros when the hex stands for bytes, because a byte should stay 8 bits long. When you only care about the number, the leading zeros mean nothing, and setting Zeros to Trim turns 0F into 1111.
Hex formats the converter reads
Upper and lower case mean the same thing. Numbers separated by a space, a comma or a new line are converted one by one. Set Group to 4 or 8 to put spaces between the bits of each result.
Example: a colour code
The colour #FF8800 is three bytes, one each for red, green and blue. Each byte runs from 00000000 for none of that colour to 11111111 for full strength.
Reading bit masks
Programmers write bit masks in hex because, with the table above in mind, the bits are easy to see. 0x80 is 10000000, only the top bit of a byte. 0x0F is 00001111, the low four bits, and 0xF0 is 11110000, the high four.
Hex that holds text
Hex from a file or a network dump often holds text, and turning it into binary will not make it readable. Paste it into the Hex Decoder to see the letters, or use the binary to hex converter to go back the other way.
Questions about hex to binary
What is FF in binary?
11111111. F is 1111, so FF is two groups of four ones. As a decimal number it is 255.
What is 0x1F in binary?
00011111, or 11111 without the leading zeros. The 0x only marks the number as hex. 1 is 0001 and F is 1111.
Why does each hex digit become four bits?
There are 16 hex digits, and four bits have exactly 16 combinations because 2 to the power 4 is 16. So each hex digit matches one group of four bits, and the conversion never needs any arithmetic beyond that table.
How many bits is a hex string?
Four bits per hex digit. 8 hex digits are 32 bits, and a SHA-256 hash written as 64 hex characters is 256 bits.
How do I turn hex into letters?
This page gives you the bits. If the hex holds text, such as 48 65 6C 6C 6F, paste it into the Hex Decoder to read it as letters.
Is my input sent to a server?
No. The conversion runs in your browser with JavaScript, and nothing you type leaves your device.