HexBinary

Digits 0–9 and A–F, with or without 0x

Try
Binary
1100 0000 1111 1111 1110 1110
Decimal 126484306 hex digits · 24 bits

Digit by digit

Each hex digit is exactly 4 bits
  1. C1100
  2. 00000
  3. F1111
  4. F1111
  5. E1110
  6. E1110
Guide

How to convert hex to binary

  1. Remove the 0x prefix if there is one.
  2. Replace each hex digit with its 4 bits from the table below. 2 is 0010 and F is 1111.
  3. Write the groups side by side in the same order. Drop leading zeros unless you need a fixed width.

Worked example

Converting 0x2F, digit by digit:

Hex digit4 bits
20010
F1111

0x2F → 0010 1111

  • Every hex digit is exactly 4 bits, so 2 hex digits make one byte and 8 make a 32-bit word.
  • Hex isn't case-sensitive: ff and FF are the same value.
  • Colors in CSS are hex too. #FF8000 is the bytes 11111111, 10000000 and 00000000 for red, green and blue.

Hex digits in binary

4 bits per digit
HexBinaryDecimal
000000
100011
200102
300113
HexBinaryDecimal
401004
501015
601106
701117
HexBinaryDecimal
810008
910019
A101010
B101111
HexBinaryDecimal
C110012
D110113
E111014
F111115
Learn

Hex to binary conversion explained

Why hexadecimal exists, how each digit maps to four bits, and where you'll meet it.

A hex to binary converter expands hexadecimal numbers into the binary digits they represent. Because each hex digit stands for exactly four bits, the conversion is quick to do by hand once you know the pattern, and this tool shows every digit next to its bits. Here's how hexadecimal works, how to convert hex to binary without a calculator, and where you'll run into hex in practice.

What hexadecimal is

Hexadecimal, or hex, is base 16. It needs sixteen digit symbols, so after 0 to 9 it borrows the letters A to F, which stand for the values 10 to 15. Each position in a hex number is worth sixteen times the one to its right: 1, 16, 256, 4,096 and so on. So 2F means 2 × 16 + 15 = 47. Hex isn't used because people like counting in sixteens. It's used because it lines up perfectly with binary.

Why every hex digit is four bits

Sixteen is 2⁴, so four bits can hold exactly sixteen different values, from 0000 to 1111. That means every hex digit corresponds to one group of four bits, sometimes called a nibble, with no overlap and nothing left over. To convert hex to binary, you never need to do any arithmetic on the whole number. You replace each digit with its four bits and write them side by side. The table further down this page lists all sixteen patterns.

Converting hex to binary by hand

Take DEADBEEF, a value programmers often use as a recognizable marker in memory. Look up each digit: D is 1101, E is 1110, A is 1010, D is 1101, B is 1011, E is 1110, E is 1110 and F is 1111. Written together, that's 1101 1110 1010 1101 1011 1110 1110 1111, a 32-bit binary number. Converting through decimal first would give the same answer, but it's much slower and easier to get wrong.

Bytes, words and leading zeros

Two hex digits make one byte, so FF is 1111 1111, or 255, the largest value a byte can hold. Eight hex digits make a 32-bit word and sixteen make a 64-bit value. When hex is used to describe bytes, leading zeros matter: 0F is the byte 0000 1111, and keeping all eight bits shows how it's stored. When you only care about the value, the leading zeros can go, and 1111 means the same number. This hex to binary converter keeps the full four bits per digit by default, and the Drop leading zeros switch removes them.

Where you'll see hexadecimal

  • Colors. CSS colors such as #FF8000 are three bytes, for red, green and blue. In binary that's 1111 1111 1000 0000 0000 0000.
  • Memory addresses and dumps. Debuggers and hex editors show memory and file contents in hex, two digits per byte.
  • Hashes and keys. A SHA-256 hash is 256 bits, usually written as 64 hex digits.
  • Network addresses. MAC addresses are 12 hex digits, and IPv6 addresses are 128 bits written as 32 hex digits.
  • Unicode. Character code points are written in hex, so U+0041 is the letter A.

Hex notation in code

Different languages and tools mark hex numbers in different ways. C, C++, Java, JavaScript, Python and most modern languages use a 0x prefix, as in 0xFF. CSS uses # for colors, and some assemblers use an h suffix, as in FFh. This converter accepts a 0x prefix and ignores spaces and underscores. For colors, leave out the #, and for MAC addresses, remove the colons first.

Hex to binary quick reference

The letters are the digits people most often need to look up. These four are worth memorizing: A is 1010 (10), C is 1100 (12), E is 1110 (14) and F is 1111 (15). From those you can find the others, because B, D and F are always one more than A, C and E: just change the last bit to 1.

Tips for converting hex to binary

Learn the 16 four-bit patterns once and you won't need a calculator for this. Every hex value, however long, is just those patterns written side by side.

FAQ

Frequently asked questions

Quick answers about the hex to binary converter and how it works.

How do I convert hex to binary?

Replace each hex digit with its 4-bit pattern and keep them in the same order. 2F becomes 0010 1111. The table on this page lists all 16 digits.

Why is each hex digit exactly 4 bits?

Hex has 16 digits, and 16 is 2⁴, so every hex digit matches one group of 4 bits exactly. That's why two hex digits make one byte, and why hex is a common shorthand for binary.

Is hex case-sensitive?

No. ff, FF and Ff are all the same value, 255, or 1111 1111.

Can I include 0x or spaces?

Yes. A leading 0x is removed, and spaces and underscores are ignored, so 0xDEAD_BEEF works.

Why does the result start with zeros?

Each digit always expands to all 4 bits, so 2 becomes 0010. That keeps the groups lined up with the digits. Turn on Drop leading zeros to remove them.

How do I convert a hex color code to binary?

Enter the code without the #. FF8000 gives 1111 1111 1000 0000 0000 0000: one byte each for red, green and blue.

Still have a question?Contact us