How to Convert From Hex to Binary: A Complete Guide
Understanding how to convert hexadecimal (hex) to binary is a foundational skill in computing, programming, and digital electronics. Whether you're debugging network addresses, reading color codes, or working with low-level hardware, knowing how these two number systems relate — and how to move between them — makes technical work significantly easier.
What Are Hexadecimal and Binary?
Binary is a base-2 number system. It uses only two digits — 0 and 1 — and is the native language of digital hardware. Every piece of data a computer processes is ultimately represented in binary.
Hexadecimal is a base-16 number system. It uses sixteen symbols: digits 0–9 plus letters A–F, where A equals 10, B equals 11, and so on up to F equals 15. Hex is widely used because it compresses binary data into a much more human-readable format.
The relationship between them is clean and deliberate: one hex digit always represents exactly four binary digits (bits), called a nibble. This 1-to-4 mapping is what makes hex-to-binary conversion straightforward once you know the lookup values.
The Core Method: Nibble-by-Nibble Conversion
The most reliable way to convert hex to binary is to replace each hex digit individually with its 4-bit binary equivalent. No math required — just substitution.
Here's the complete hex-to-binary lookup table:
| Hex Digit | Binary Equivalent |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
Step-by-Step Example
Convert hex 2F to binary:
- Take the first digit:
2→0010 - Take the second digit:
F→1111 - Combine them in order:
00101111
Convert hex A3C to binary:
A→10103→0011C→1100- Result:
101000111100
That's the entire process. No division, no remainders — just direct substitution digit by digit.
Why This Conversion Matters 🔢
Hex is used as shorthand precisely because it maps so cleanly to binary. A single byte (8 bits) of binary data can be represented by exactly two hex digits, which is why you'll see hex everywhere in computing contexts:
- Memory addresses — e.g.,
0x1A4F - RGB color codes — e.g.,
#FF5733 - MAC addresses — e.g.,
00:1A:2B:3C:4D:5E - Machine code and assembly language
- Cryptographic hashes and checksums
When you see a hex value in any of these contexts, converting it to binary reveals the actual bit-level data the system is working with.
Handling Hex Prefixes and Notation
Hex values are written in several ways depending on the context:
0xprefix — Common in programming (e.g.,0xFF)#prefix — Used in color codes (e.g.,#FF)hsuffix — Sometimes used in assembly (e.g.,FFh)
When converting, ignore the prefix or suffix — it's just notation. Only the hex digits themselves get converted.
Tools and Methods Depending on Your Use Case
How you actually perform the conversion in practice depends on what you're doing and your comfort level with the math.
Manual lookup works well when you're learning, converting short values, or need to understand what you're reading at the bit level. Memorizing the 0–F table (or keeping it handy) is enough.
Scientific calculators — including the Windows Calculator in Programmer mode and macOS Calculator in Programmer view — handle hex-to-binary conversion instantly. You enter the hex value and switch the display to binary.
Programming languages make this trivial in code:
- Python:
bin(int('2F', 16))returns'0b101111' - JavaScript:
parseInt('2F', 16).toString(2)returns'101111'
Online converters are available for quick one-off conversions, though they vary in how they handle edge cases like leading zeros.
Where Leading Zeros Matter
One subtlety worth knowing: leading zeros are often significant in hardware and protocol contexts. 🔍
For example, hex 09 converts to 00001001, not just 1001. If you're working with a fixed-width data format — like an 8-bit register, a full byte in a network packet, or a 32-bit memory address — dropping leading zeros will misrepresent the data structure.
Whether you need to preserve them depends entirely on the context:
- Casual reading or learning — leading zeros are often dropped for simplicity
- Hardware registers, protocols, memory — leading zeros must be preserved to maintain correct bit positions
- Color codes and cryptographic values — fixed-width formats where every bit position counts
The Reverse Is Just as Simple
Binary to hex works by grouping bits into sets of four from right to left, then converting each group back using the same table. The same 1-to-4 relationship applies in both directions.
The conversion method itself is consistent and reliable — the lookup table doesn't change. What varies is how and where you apply it: whether you're reading raw binary output from a hardware debugger, parsing color values in a design tool, or writing low-level code. The precision you need, the tools available to you, and the format requirements of your specific system all shape what a "correct" conversion looks like in practice.