Hex to Binary Conversion: Complete Guide with Table & Examples
Learn how to convert hexadecimal to binary with a complete 0-F conversion table, worked examples, programming code in Python/JavaScript/Java/C, and common hex values every developer should know.
Hex to Binary Conversion: Complete Guide with Table & Examples
Hexadecimal-to-binary conversion is one of the most fundamental skills in computing. Whether you are reading memory dumps, inspecting network packets, styling web pages with color codes, or debugging low-level firmware, the ability to move fluently between hex and binary is indispensable. The good news: it is also one of the easiest conversions to learn, because the two number systems share a clean mathematical relationship.
This guide covers everything you need to know about hex-to-binary conversion. By the end, you will be able to convert any hex value to binary by hand, understand why the conversion works, and write code that performs the conversion in four different programming languages. Try our free hex to binary converter to follow along with any of the examples below.
What Is Hexadecimal?
Hexadecimal -- often shortened to hex -- is a base-16 number system. It uses sixteen distinct symbols to represent values:
- 0-9 for values zero through nine
- A-F (or a-f) for values ten through fifteen
| Hex Digit | Decimal Value |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| A | 10 |
| B | 11 |
| C | 12 |
| D | 13 |
| E | 14 |
| F | 15 |
Why Computers Use Hexadecimal
Computers work in binary, but binary strings are long and error-prone for humans to read. Decimal is familiar to humans but does not align neatly with binary. Hexadecimal offers the best of both worlds: each hex digit represents exactly 4 binary bits, making it a compact, human-readable shorthand for binary data.
Consider the byte value 11010110 in binary. In decimal it is 214, which requires mental arithmetic to verify. In hex it is simply D6 -- two characters that can be verified digit by digit against a small lookup table.
Common Uses of Hexadecimal
- Web color codes:
#FF5733,#3A7BD5,#000000 - Memory addresses:
0x7FFF5FBFF8AC - MAC addresses:
00:1A:2B:3C:4D:5E - Unicode code points:
U+0041(the letter A) - Cryptographic hashes: SHA-256 produces 64 hex digits
- Assembly language: machine code operands are written in hex
- IPv6 addresses:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
What Is Binary?
Binary is a base-2 number system that uses only two symbols: 0 and 1. It is the fundamental language of all digital computers, because electronic circuits are most reliably built around two-state (on/off) logic.
Bits, Nibbles, and Bytes
- A bit is a single binary digit (0 or 1).
- A nibble is 4 bits. One nibble can represent 16 values (0-15), which maps perfectly to one hex digit.
- A byte is 8 bits (2 nibbles). One byte can represent 256 values (0-255), which maps to exactly two hex digits (00-FF).
- A word varies by architecture but is commonly 16, 32, or 64 bits.
The nibble is the key unit for hex-to-binary conversion. Since one hex digit equals one nibble, converting between the two systems is a simple substitution.
How to Convert Hex to Binary
The core rule is straightforward: replace each hexadecimal digit with its 4-bit binary equivalent.
The 4-Bit Mapping Rule
Because 16 = 2^4, each hex digit maps to exactly 4 binary bits. This is not an approximation or a shortcut -- it is an exact mathematical correspondence. The full mapping is:
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Step 1: Write Down the Hex Number
Remove any prefix or notation. Common prefixes include:
0x(C, Java, Python, JavaScript):0xFFbecomesFF#(CSS color codes):#3A7BD5becomes3A7BD5$(6502 assembly):$FFbecomesFFhsuffix (Intel assembly):FFhbecomesFF
Step 2: Replace Each Hex Digit with 4-Bit Binary
Working left to right, substitute each hex digit using the table above. Always use the full 4-bit representation, including leading zeros.
Step 3: Combine All Groups
Concatenate the 4-bit groups. The result is the complete binary representation. You may optionally add spaces between nibble groups for readability.
Hex to Binary Conversion Table
Here is the definitive reference table for single hex digit to binary conversion, including the decimal equivalent:
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Extended Examples for Multi-Digit Values
| Hex | Decimal | Binary |
|---|---|---|
| 00 | 0 | 0000 0000 |
| 0F | 15 | 0000 1111 |
| 10 | 16 | 0001 0000 |
| 7F | 127 | 0111 1111 |
| 80 | 128 | 1000 0000 |
| FF | 255 | 1111 1111 |
| 100 | 256 | 0001 0000 0000 |
| FFFF | 65535 | 1111 1111 1111 1111 |
For any hex value, you can instantly verify the conversion using our hex to binary converter.
Worked Examples
Simple: A to Binary
Hex input: A
- A = 1010
Result: 1010 (decimal 10)
This is the most basic conversion: a single hex digit to a single nibble.
Medium: 2F to Binary
Hex input: 2F
- 2 = 0010
- F = 1111
Result: 0010 1111 (decimal 47)
Each digit converts independently, then the nibbles are concatenated.
Complex: DEADBEEF to Binary
Hex input: DEADBEEF
This is a famous "hexspeak" value used as a magic number in software debugging.
- D = 1101
- E = 1110
- A = 1010
- D = 1101
- B = 1011
- E = 1110
- E = 1110
- F = 1111
Result: 1101 1110 1010 1101 1011 1110 1110 1111
That is 32 bits (4 bytes), or the full width of a 32-bit integer. In decimal, DEADBEEF equals 3,735,928,559.
Color Codes: #FF5733 to Binary
Hex input: FF5733 (a warm orange-red color)
- F = 1111
- F = 1111
- 5 = 0101
- 7 = 0111
- 3 = 0011
- 3 = 0011
Result: 1111 1111 0101 0111 0011 0011
The 24 bits break into three RGB bytes:
- Red: 11111111 = 255
- Green: 01010111 = 87
- Blue: 00110011 = 51
You can also explore hex color values with our hex to RGB converter.
With 0x Prefix: 0x1A3F to Binary
Hex input: 0x1A3F (strip the 0x prefix first)
- 1 = 0001
- A = 1010
- 3 = 0011
- F = 1111
Result: 0001 1010 0011 1111 (decimal 6,719)
The 0x prefix is just a notation convention used in C, Java, Python, and JavaScript to indicate that the number is hexadecimal. It does not affect the conversion.
Converting Binary Back to Hex
The reverse process is equally straightforward:
- Group into 4-bit nibbles from right to left. Start at the least significant (rightmost) bit and form groups of four.
- Pad with leading zeros if needed. If the leftmost group has fewer than 4 bits, add zeros on the left.
- Replace each 4-bit group with its hex equivalent.
Worked Example
Binary input: 110101101
Step 1: Group from the right: 1 1010 1101
Step 2: Pad leftmost group: 0001 1010 1101
Step 3: Convert each group:
- 0001 = 1
- 1010 = A
- 1101 = D
Result: 1AD (decimal 429)
Hex to Binary in Programming Languages
Python
Python's int() function parses hex strings, and bin() converts to binary:
JavaScript
JavaScript uses parseInt() for hex parsing and .toString(2) for binary output:
Java
Java provides Integer.parseInt() and Integer.toBinaryString():
C/C++
C and C++ use strtol() or direct bitwise operations:
Common Hex Values Every Developer Should Know
Boundary Values
| Hex | Binary | Decimal | Significance |
|---|---|---|---|
| 0x00 | 0000 0000 | 0 | Null byte, minimum byte value |
| 0x7F | 0111 1111 | 127 | Max signed 8-bit integer |
| 0x80 | 1000 0000 | 128 | Min signed 8-bit (two's comp.) |
| 0xFF | 1111 1111 | 255 | Max unsigned 8-bit (1 byte) |
| 0xFFFF | 1111 1111 1111 1111 | 65,535 | Max unsigned 16-bit |
| 0xFFFFFFFF | 1111 1111 1111 1111 1111 1111 1111 1111 | 4,294,967,295 | Max unsigned 32-bit |
Web Color Values
| Hex | Binary | Color |
|---|---|---|
| #000000 | 0000 0000 0000 0000 0000 0000 | Black |
| #FFFFFF | 1111 1111 1111 1111 1111 1111 | White |
| #FF0000 | 1111 1111 0000 0000 0000 0000 | Red |
| #00FF00 | 0000 0000 1111 1111 0000 0000 | Green |
| #0000FF | 0000 0000 0000 0000 1111 1111 | Blue |
| #FF5733 | 1111 1111 0101 0111 0011 0011 | Orange |
| #3A7BD5 | 0011 1010 0111 1011 1101 0101 | Blue |
ASCII Codes in Hex
| Hex | Binary | Character |
|---|---|---|
| 0x20 | 0010 0000 | Space |
| 0x30 | 0011 0000 | '0' |
| 0x41 | 0100 0001 | 'A' |
| 0x61 | 0110 0001 | 'a' |
| 0x7E | 0111 1110 | '~' |
Knowing these values by heart speeds up debugging, memory inspection, and low-level programming tasks significantly.
Frequently Asked Questions
How do you convert hex to binary?
Replace each hex digit with its 4-bit binary equivalent. The mapping is: 0=0000, 1=0001, 2=0010, ..., 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. For example, hex 2F becomes 0010 1111. This works because 16 = 2^4, so each hex digit represents exactly 4 binary bits.
What is 0xFF in binary?
0xFF in binary is 11111111 (eight 1-bits). F in hex is 1111 in binary, so FF becomes 1111 1111. This equals 255 in decimal and represents the maximum value of a single unsigned byte.
How many binary digits does one hex digit represent?
Exactly 4 binary digits (bits). This is because hexadecimal is base-16 and 16 = 2^4. One hex digit can represent values 0-15, which is exactly the range of 4 bits (0000 to 1111).
What is DEADBEEF in binary?
DEADBEEF in hex converts to 11011110 10101101 10111110 11101111 in binary. It equals 3,735,928,559 in decimal. This is a famous "hexspeak" magic number used in debugging to fill uninitialized memory.
How do you convert binary back to hex?
Group the binary digits into sets of 4 from right to left, padding the leftmost group with leading zeros if needed. Then replace each 4-bit group with its hex equivalent. For example, binary 10110010 groups as 1011 0010, which converts to B2 in hex.
Why is hexadecimal used instead of binary?
Hexadecimal is used because it is much more compact and readable than binary while still maintaining a direct mathematical relationship. The byte value 11010110 in binary is simply D6 in hex -- two characters instead of eight, with no arithmetic required to convert between them.
What is the difference between hex and binary?
Hexadecimal is base-16 (using digits 0-9 and letters A-F) while binary is base-2 (using only 0 and 1). Hex is a human-friendly representation of binary data: each hex digit encodes exactly 4 binary bits. Computers operate in binary internally, but developers use hex as a convenient notation.
Can you convert hex to binary without a calculator?
Yes. Once you memorize the 16 mappings (0=0000 through F=1111), you can convert any hex number to binary by hand in seconds. The conversion is a simple one-to-one substitution for each digit, with no carrying, borrowing, or arithmetic involved.
How do hex color codes relate to binary?
A hex color code like #FF5733 is a 24-bit binary value split into three 8-bit channels: Red (FF = 11111111 = 255), Green (57 = 01010111 = 87), and Blue (33 = 00110011 = 51). The hex notation is simply a compact way to represent the 24 binary bits that define the color.
What is the largest hex value that fits in one byte?
FF (decimal 255, binary 11111111). A byte is 8 bits, and the maximum value of 8 bits is 11111111, which equals F (1111) followed by F (1111) in hex. This is why byte values in hex always range from 00 to FF.
Summary
Hex-to-binary conversion is a foundational skill built on one simple rule: each hex digit equals exactly 4 binary bits. Whether you are converting a single digit like A (1010), a byte like FF (11111111), or a complex value like DEADBEEF, the process is always the same mechanical substitution.
The key takeaways from this guide:
- 16 = 2^4, so one hex digit = one 4-bit nibble
- Memorize the 0-F table and you can convert any hex number to binary instantly
- Two hex digits = one byte (8 bits), making hex the natural notation for byte-oriented data
- Programming languages provide built-in functions: Python's
bin(int(x, 16)), JavaScript'sparseInt(x, 16).toString(2), Java'sInteger.toBinaryString(Integer.parseInt(x, 16)) - The reverse conversion (binary to hex) works by grouping bits into nibbles from the right
Ready to practice? Use our free hex to binary converter to convert any hexadecimal value to binary instantly, with step-by-step nibble-by-nibble breakdown and 4-bit group visualization.