FLXCode Hex to Binary Converter

FLXCode apps

Appearance

Hex to Binary Converter

Type a hex number such as A5F3 or 0xFF and get its bits. Each hex digit turns into four binary digits.

Example

1010 0101 1111 0011

A5F3 in base 16 (hexadecimal) is 1010010111110011 in base 2 (binary) (42483 in decimal).

Steps

  1. Each digit is worth its value times a power of 16: A5F3 = 10 × 16³ + 5 × 16² + 15 × 16¹ + 3 × 16⁰ = 42483.
  2. Divide by 2 again and again. The remainders, read from the last to the first, are the digits: 42483 ÷ 2 = 21241 remainder 1; 21241 ÷ 2 = 10620 remainder 1; 10620 ÷ 2 = 5310 remainder 0; 5310 ÷ 2 = 2655 remainder 0; 2655 ÷ 2 = 1327 remainder 1; 1327 ÷ 2 = 663 remainder 1; 663 ÷ 2 = 331 remainder 1; 331 ÷ 2 = 165 remainder 1; 165 ÷ 2 = 82 remainder 1; 82 ÷ 2 = 41 remainder 0; 41 ÷ 2 = 20 remainder 1; 20 ÷ 2 = 10 remainder 0; 10 ÷ 2 = 5 remainder 0; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1.

The same number in the common bases

BaseValue
base 2 (binary)1010 0101 1111 0011
base 8 (octal)122763
base 10 (decimal)42483
base 16 (hexadecimal)A5F3

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.

Problem or idea? Email us

Worked examples

HexBinaryNote
F1111The largest single digit
A51010 0101Alternating bit pattern, a common test value
0xFF1111 1111The 0x prefix is accepted
3C0011 1100Two bits set in each half
DEADBEEF1101 1110 1010 1101 1011 1110 1110 1111Eight digits, 32 bits
7F0111 1111The largest signed 8-bit value
0.80.1A hex fraction: 8 sixteenths is one half

Doing it on paper

Write the hex number, then write four bits under each digit. For 2F9 the bits are 0010, 1111, 1001, joined as 0010 1111 1001.

If you forget a digit, rebuild it from the weights 8, 4, 2 and 1. C is 12, which is 8 + 4, so the bits are 1100.

All sixteen digits

Hex digitBitsWeights set
000000
100011
200102
300112 + 1
401004
501014 + 1
601104 + 2
701114 + 2 + 1
810008
910018 + 1
A10108 + 2
B10118 + 2 + 1
C11008 + 4
D11018 + 4 + 1
E11108 + 4 + 2
F11118 + 4 + 2 + 1

What to do with the bits

With the bits in front of you it is easy to see which flags are set, or to build a mask. To flip, set or test single bits, open the programmer calculator, where every bit is a button. To go from bits back to hex use binary to hex. The number base converter handles every base from 2 to 36.

Numbers this uses

  • Digits 0 to 9 and A to F in either case. A 0x prefix, spaces and underscores are ignored.
  • Up to 1,000 characters, exact (BigInt). A hex fraction is allowed.
  • The result is plain binary grouped in fours, not a fixed-width register.

Nothing you type is uploaded. We count events without cookies (details).

FAQ

How do I convert hex to binary?

Replace every hex digit with its four bits and keep the order. 2F9 becomes 0010, 1111, 1001, so 0010 1111 1001. No arithmetic is needed, just the table above.

Do I keep the leading zeros?

Inside the number, yes: each digit gives four bits, so a 2 after another digit is 0010. In front of the whole number the tool drops zero digits (0A5 gives 1010 0101) but keeps the first group four bits wide (2 gives 0010). For a fixed 8, 16, 32 or 64-bit width use the programmer calculator.

What is the binary of FF?

1111 1111. Two F digits, four ones each. In 8-bit unsigned it is 255. Read as an 8-bit signed number the same bits mean -1.

Can I type 0x, lowercase letters or spaces?

Yes. 0xff, FF and de ad be ef all work. Underscores are ignored too. A web colour with a # in front needs the # removed first.

How do I turn a hex colour into bits?

Take the pairs one at a time. #FF8800 is FF, 88 and 00: 1111 1111, 1000 1000 and 0000 0000. Each pair is one byte, the red, green or blue channel.

Does it work for very long values?

Up to 1,000 characters, converted exactly with BigInt. A 256-bit key written as 64 hex digits gives all 256 bits, with no rounding.

Why is the answer shown in groups of four?

Each group is one hex digit, so you can match the answer to your input digit by digit. The copy button gives the plain bits without spaces.

Is my number sent or stored anywhere?

No. It is converted in your browser. What you type is not put in the address bar, not stored and not counted. Only the base you converted to is counted.

More from FLXCode

Share Hex to Binary Converter