Hex to binary converter

Type a hexadecimal (hex) number and see its bits: FF is 11111111 and 3E8 is 1111101000. Each hex digit turns into four bits, and "Show the working" lays out that mapping digit by digit. Pad to 8 bits, split into nibbles or add a 0b prefix from the Output menu.

Binary to hex

Show the working
One number per line, or separate them with spaces.0 numbers
Reviewed bySam Siewert
Last updated · How we test

Runs in your browser. Nothing you type is uploaded.

How to use the converter

  1. Type or paste hex values. Upper and lower case both work, and 0x, # or a trailing h are accepted.
  2. Choose plain binary, 8-bit padding, 4-bit groups, 8-bit groups or a 0b prefix.
  3. Copy, download or share the output.

Width and Signed. Pick a Width to pad the binary to 8, 16, 32 or 64 bits, so 3E8 at 16 bits becomes 0000001111101000. Tick Signed to read the hex as two's complement; the bits stay the same, and the decimal value under the boxes turns negative when the top bit is 1. Octal is shown there too. Open file loads a .txt or .csv list of hex values.

What the converter does with different hex

Hex copied from code, a color picker or a datasheet comes in several shapes. Each input below was typed into the converter on this page, with Output on Plain and Width on Auto unless the row says otherwise.

InputWhat you get
0x2ED (C-style prefix)1011101101
2EDh (assembly suffix)1011101101
$2ED (Pascal-style prefix)1011101101
2ed (lowercase)1011101101
#FF8800 (a color code)111111111000100000000000. All 24 bits as one number. Pick 8-bit groups to see red, green and blue apart.
FF_FF (underscore between groups)1111111111111111
1A.8 (a hex fraction)11010.1. The 8 after the point is 8/16, one half, which is .1 in binary. The decimal line shows 26.5.
-2ED (minus sign)-1011101101
2E D (a space inside the value)101110 and 1101, two separate values. Remove the space.
2ED with Output set to Pad to 8 bits0000001011101101, padded to two full bytes, 16 bits
2ED with Output set to 4-bit groups0010 1110 1101
FF with Width 8-bit and Signed ticked11111111. The bits do not change. The decimal line under the boxes reads -1.
1FF with Width 8-bitNo result. The message says 1FF does not fit in 8 bits and that the largest 8-bit value is FF.
\x48 (escape from a C or Python string)Not accepted. Delete the \x first.
G1 (a letter past F)No result. The message says hex can only use 0 to 9 and A to F, and names the G.
The hex to binary converter with four inputs on separate lines: 0x2ED, #FF8800, 2EDh and 1A.8. The binary column reads 1011101101, 111111111000100000000000, 1011101101 and 11010.1.
Four inputs in one list. The 0x prefix and the h suffix give the same bits for 2ED, the color code comes back as one 24-bit number, and 1A.8 keeps its fraction.

How to convert hexadecimal to binary

Write each hex digit as its 4-bit pattern and join the patterns up. Every digit gets all four bits, including zeros, with one exception: zeros at the very front of the result can be dropped because they do not change the value.

Hex 3E8 expanded digit by digit: 3 becomes 0011, E becomes 1110 and 8 becomes 1000, giving 1111101000 once the two leading zeros are dropped.

For 3E8: 3 is 0011, E is 1110 and 8 is 1000. Joined, that is 001111101000, or 1111101000 without the leading zeros, which is 1000 in decimal. For 2F: 2 is 0010 and F is 1111, giving 101111.

The mistake to watch for is dropping zeros from a digit in the middle or at the end. If you write the 0 in A0 as a single 0 instead of 0000, you get 10100 (20) instead of 10100000 (160).

Hex to binary chart

Chart of all sixteen 4-bit binary patterns from 0000 to 1111 with their hex digits 0 to 9 and A to F and decimal values 0 to 15.
HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

A quick way to rebuild any row: the four bits are worth 8, 4, 2 and 1. B is 11, and 11 = 8 + 2 + 1, so B is 1011. If you know A is 10 and F is 15, the letters in between follow in order.

Worked examples

HexDigit by digitBinaryDecimal
1F0001 11111111131
2F0010 111110111147
7F0111 11111111111127
A01010 000010100000160
F01111 000011110000240
FF1111 111111111111255
2ED0010 1110 11011011101101749
3E80011 1110 100011111010001000
DEADBEEF1101 1110 1010 1101 1011 1110 1110 111132 bits3735928559
The hex to binary converter with Show the working open for 2ED. The working lists 2 as 0010, E as 1110 and D as 1101, and the result 1011101101. The line above shows octal 1355 and decimal 749.
2ED with the working open. Each digit becomes four bits, and the decimal line above confirms 749.

Where you meet hex to binary

Bit masks are usually written in hex. 0xF0 is 11110000, so ANDing a byte with it keeps the top four bits and clears the bottom four. Seeing the mask in binary makes it obvious which bits it touches. The Wikipedia article on masks has more examples, and the binary calculator runs AND, OR and XOR for you.

Color codes are another everyday case. In the six-digit CSS hex color format, a color is three bytes, one each for red, green and blue.

The CSS color #FF8800 split into red FF (11111111, 255), green 88 (10001000, 136) and blue 00 (00000000, 0).

Type FF8800 and choose "8-bit groups" in the Output menu to get that split in one step. Memory dumps and debuggers work the same way: 0xDEADBEEF, a value programmers often use to mark uninitialized memory, expands to the 32 bits shown in the table above.

The hex to binary converter with Output set to 8-bit groups and the input FF8800. The binary output is 11111111 10001000 00000000, and the byte order line shows FF 88 00 big-endian and 00 88 FF little-endian.
FF8800 with Output on 8-bit groups. The three bytes are red 11111111, green 10001000 and blue 00000000.

Hex that holds text

If your hex is a run of byte values like 48 65 6C 6C 6F, it is probably text. This page treats each group as a number, so 48 69 becomes 1001000 and 1101001. To read the bytes as characters, use hex to text, which turns 48 69 into "Hi".

Hex to binary in code

Python: bin(int('3E8', 16)) returns '0b1111101000', and format(int('3E8', 16), '012b') keeps all twelve bits. JavaScript: parseInt('3E8', 16).toString(2) returns "1111101000"; for long values use BigInt('0x' + hex).toString(2).

To go back from bits to hex, use binary to hex. For the decimal value, try hex to decimal.

Frequently asked questions

What is F in binary?

1111, the largest 4-bit value (15).

What is 0110 in hex?

6. The bits worth 4 and 2 are on, and 4 + 2 = 6, which is the same digit in hex and decimal.

What is 7F in binary?

01111111, or 127 in decimal. It is the largest value a signed 8-bit number can hold.

How many bits is one hex digit?

Four. Two hex digits make one byte of 8 bits, so a 32-bit value is 8 hex digits long.

Can I convert very long hex values?

Yes. A 64-character SHA-256 hash converts exactly. "Pad to 8 bits" adds zeros at the front so the output is a whole number of bytes.

Scroll to Top