Skip to content
Hexadecimal Converter

Hex to Binary Converter

To convert hex to binary, replace each hex digit with its four-bit group, called a nibble: 0 is 0000, 9 is 1001, A is 1010 and F is 1111. Write the groups in the same order. For example, 3C9 becomes 0011 1100 1001; drop the leading zeros if you want 1111001001.

Method: One hex digit, four bits
Replace each hex digit with four bits
Hex digitBits
30011
C1100
91001

Write the groups in order: 0011 1100 1001.

How to convert hex to binary by hand

No arithmetic is involved. Sixteen is two to the fourth, so each hex digit stands for exactly one pattern of four bits and the patterns never interact. You can translate a value of any length one character at a time, in any order, and still get the right answer.

  1. Take the hex digits one at a time, left to right.
  2. Look up each digit’s four-bit group in the nibble table.
  3. Write the groups side by side in the same order, keeping every inner zero.
  4. Optionally drop the zeros at the very front, unless you need a fixed width.

The one rule to respect is padding inside the number. The digit 3 is 0011, not 11: if you shorten an inner group, every bit to its left slides into the wrong place and the value changes.

Worked example: 3C9

Three digits become three nibbles, twelve bits

3C916 = 0011 1100 10012

Replace each hex digit with four bits
Hex digitBits
30011
C1100
91001

Write the groups in order: 0011 1100 1001.

The nibble table

A nibble is half a byte. These sixteen rows are the whole lookup; learn a few anchors and the rest follow. 8 is a lone high bit (1000), F is all four set, and A and 5 are the alternating patterns 1010 and 0101 that test engineers like because neighboring bits differ.

A digit and its complement to F are bit-for-bit opposites: 3 and C, 6 and 9, 1 and E. That pairing is handy when you are checking a mask and its inverse.

Hex digit, four bits, decimal value
HexBinaryDecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115

Reading flag bytes

Status registers and option fields pack several yes-or-no switches into one byte, and documentation lists them as hex masks. Expanding the byte to bits shows which switches are on. The 6502 processor status register, laid out in MOS Technology’s MCS6500 programming manual, is a classic: a value of C3 is 1100 0011, so Negative, Overflow, Zero and Carry are set.

Each mask has a single 1 in it, so it is always 1, 2, 4 or 8 in one of the two digit positions. Testing a flag in code is status & 0x40, and the hex calculator can show that AND bit by bit.

Some 6502 status flags and their masks
BitMaskBitsFlag
0010000 0001Carry
1020000 0010Zero
2040000 0100Interrupt disable
3080000 1000Decimal mode
6400100 0000Overflow
7801000 0000Negative

When to keep the leading zeros

Mathematically, 0011 1100 1001 and 1111001001 are the same number. Which one to write depends on what the bits mean. A register, a byte in a packet or a pixel channel has a fixed size, and the high zeros are real bits that happen to be off; dropping them hides the size. A plain quantity has no width, and the short form is cleaner.

The converter always groups binary in nibbles and keeps the zeros needed to complete the leftmost group only when a bit width is chosen on the home converter. Here the result keeps its natural length.

Questions people ask

Why does each hex digit equal four binary digits?

Because 16 = 2⁴. Four bits have exactly 16 combinations, 0000 to 1111, one for each hex digit from 0 to F, so every hex digit maps to one fixed group of four bits.

What is FF in binary?

11111111. Each F is 1111, so FF is two full nibbles, eight ones in a row, which is 255 in decimal.

Should I keep leading zeros when converting hex to binary?

Inside the number, yes: 3C9 must be written 0011 1100 1001 so each digit keeps its four bits. Only the zeros at the very front can be dropped, giving 1111001001; keep them when you need a fixed width such as a full byte.

What is 0xA in binary?

1010. A is 10 in decimal, which is 8 + 2, so the bits worth 8 and 2 are set.

Last updated