What is hex to binary conversion?
Hex to binary conversion changes a number from base 16 to base 2. Each hex digit maps to exactly four binary digits (bits), because 16 = 2⁴. Replace every hex digit with its 4-bit pattern and join the groups from left to right.
Hex 3C converts in two steps: 3 → 0011 and C → 1100, so the result is 00111100.
No arithmetic is needed. This direct one-to-four mapping is why processors, debuggers and network tools show data in hex: hex keeps the bit structure that decimal hides. Type your own value and tap any bit to flip it.
Hexadecimal number system (base 16)
The hexadecimal system uses sixteen digits: 0–9 for the values 0 to 9 and A–F for 10 to 15. Each position is worth sixteen times the position to its right, so hex 5A = 5 × 16 + 10 = 90 in decimal.
Common hex notations include the 0x prefix in C, Python and JavaScript, the # prefix in HTML and CSS colour codes, and the h suffix in assembly language.
Binary number system (base 2)
The binary system uses two digits, 0 and 1, called bits. Each position is worth twice the position to its right: the rightmost bit is 2⁰ = 1, the next is 2¹ = 2, then 2² = 4, 2³ = 8, and so on. Computers store and process all data in binary because transistors have two stable states: on (1) and off (0).
A group of 4 bits is a nibble, and a group of 8 bits (two nibbles) is a byte. One hex digit stands for one nibble, and two hex digits stand for one byte.
Hex digit to binary chart (nibble table)
Each hex digit maps to one fixed 4-bit pattern. Learn this chart or look it up during conversion. Flip the four switches to find the digit for any pattern, or pick a digit to see its bits.
The chart works in both directions. To convert binary to hex, split the bits into groups of four from the right, pad the leftmost group with zeros, and look up each group.
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| Hex | Binary | Decimal |
|---|---|---|
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
How to convert hex to binary
Step-by-step method
- Write the hex number with each digit separated.
- Replace each digit with its 4-bit pattern from the nibble chart.
- Join the 4-bit groups in the same left-to-right order.
- Drop the leading zeros from the result, or keep them to match a bit width (8, 16, 32 or 64 bits).
Hex to decimal to binary
The decimal value gives a quick check on the bits: add the place value of every 1 bit. For 3C, the set bits are 32, 16, 8 and 4, and 32 + 16 + 8 + 4 = 60, which matches 3 × 16 + 12. For longer values, use the hex to decimal converter. For base 8, use the hex to octal converter.
Hex to binary conversion examples
Example 1: convert A5 to binary
A is 1010 and 5 is 0101. Join the groups: A5 = 10100101. That is 1 byte (8 bits). Check: 128 + 32 + 4 + 1 = 165, and A × 16 + 5 = 165.
Example 2: convert FF to binary
F is 1111 twice, so FF = 11111111. All 8 bits are set, so the decimal value is 255, the largest unsigned byte value.
Example 3: convert 7E8 to binary
7 is 0111, E is 1110 and 8 is 1000. Join the groups: 7E8 = 011111101000. Drop the leading zero to get 11111101000 (11 bits). The decimal value is 2,024.
Example 4: convert DEADBEEF to binary
| Hex digit | D | E | A | D | B | E | E | F |
|---|---|---|---|---|---|---|---|---|
| Binary | 1101 | 1110 | 1010 | 1101 | 1011 | 1110 | 1110 | 1111 |
Join the groups: DEADBEEF = 11011110101011011011111011101111. That is 32 bits (4 bytes), a common test pattern in memory debugging. Pick any example below to watch it split.
Binary to hex conversion
To reverse the process, split the bits into groups of four from the right and look up each group.
For 11010110, the groups are 1101 and 0110. Since 1101 is D and 0110 is 6, the result is D6.
If the leftmost group has fewer than four bits, pad it with zeros on the left. The binary 10110 becomes 0001 0110, which is 16 in hex.
Bytes and bit widths
A byte holds 8 bits and takes exactly 2 hex digits. The size box in the converter shows the bit and byte count of whatever you type.
| Hex digits | Bits | Bytes | Range (unsigned) |
|---|---|---|---|
| 1 | 4 | ½ (nibble) | 0–15 |
| 2 | 8 | 1 | 0–255 |
| 4 | 16 | 2 | 0–65,535 |
| 8 | 32 | 4 | 0–4,294,967,295 |
| 16 | 64 | 8 | 0–18,446,744,073,709,551,615 |
The standard integer types in most languages (uint8, uint16, uint32, uint64) match these widths. A byte is the smallest addressable unit on most machines, and addresses use hex because each byte maps to exactly two hex digits.
Bit numbering, MSB and LSB
The most significant bit (MSB) is the leftmost bit, and the least significant bit (LSB) is the rightmost. In hex, the leftmost digit holds the MSB and the rightmost digit holds the LSB.
For 0xA5 = 10100101, bit 7 (the MSB) is 1 and bit 0 (the LSB) is 1. Bit 7 carries a place value of 128, while bit 0 carries 1.
Signed integers use the MSB as the sign bit. In two’s complement, MSB = 0 means positive and MSB = 1 means negative. Hex 0x7F = 01111111 is +127, the largest signed 8-bit value, and 0x80 = 10000000 is −128, the smallest. Switch the visual to signed to see it. For signed conversion at a set width, use the signed hex to decimal converter.
Why programmers use hex instead of binary
A 32-bit value takes 32 binary digits but only 8 hex digits. Hex keeps the bit pattern readable because each digit lines up with one nibble. Three common uses show why:
- Bit masks. The mask 0xF0 = 11110000 selects the high nibble of a byte, and 0x0F = 00001111 selects the low nibble. In hex, the mask’s purpose shows at a glance.
- Memory addresses. A 64-bit address such as 0x00007FFE5A100000 is 16 hex digits instead of 64 binary digits. Debuggers show addresses in hex for this reason.
- Colour codes. The CSS colour #1E90FF splits into red 1E, green 90 and blue FF. Each channel is one byte, and its two hex digits map straight to 8 bits.
Hex to binary in programming
Most languages convert hex to binary with built-in format functions. Pick a language to see the call and its output for your value.
Python
n = int('3C', 16)
bin(n) # '0b111100'
format(n, '08b') # '00111100' (zero-padded to 8 bits)
f'{n:032b}' # 32-bit binary stringPython’s int() with base 16 parses the hex string, and bin() or format() produces the binary. For the full guide, see hex to decimal in Python.
JavaScript
const n = parseInt('3C', 16);
n.toString(2); // '111100'
n.toString(2).padStart(8, '0'); // '00111100'parseInt with radix 16 parses the hex, and toString(2) returns the binary. For the full guide, see hex to decimal in JavaScript.
C
#include <stdio.h>
int main(void) {
unsigned n = 0x3C;
for (int i = 7; i >= 0; i--)
putchar('0' + ((n >> i) & 1));
putchar('\n'); // prints 00111100
return 0;
}C has no built-in binary format specifier. Use bit shifting to read each bit from the MSB to the LSB. For the full guide, see hex to decimal in C.
Other languages
| Language | Hex to binary | Example | Result |
|---|---|---|---|
| Java | Integer.toBinaryString() | Integer.toBinaryString(0x3C) | "111100" |
| Excel | =HEX2BIN() | =HEX2BIN("3C", 8) | "00111100" |
| Bash | bc | echo "obase=2;ibase=16;3C" | bc | 111100 |
Each language has its own guide on this site: Java, Excel and Linux and Bash.
Hex to binary conversion table (00–FF)
The grid and table below cover every byte from 00 to FF with its 8-bit binary pattern and decimal value. Find the hex byte, then read the bits across. The first four bits come from the left hex digit and the last four from the right one.
Common values
| Hex | Binary | Decimal | Where you meet it |
|---|---|---|---|
00 | 00000000 | 0 | Null byte, zero flag |
0F | 00001111 | 15 | Low-nibble mask |
3C | 00111100 | 60 | ASCII less-than sign (<) |
55 | 01010101 | 85 | Alternating-bit test pattern |
7F | 01111111 | 127 | Largest signed 8-bit integer |
80 | 10000000 | 128 | Smallest signed 8-bit integer (−128 in two’s complement) |
AA | 10101010 | 170 | Alternating-bit test pattern |
F0 | 11110000 | 240 | High-nibble mask |
FF | 11111111 | 255 | Largest unsigned byte, all bits set |
Full table
| Hex | Binary | Dec |
|---|---|---|
| 00 | 00000000 | 0 |
| 01 | 00000001 | 1 |
| 02 | 00000010 | 2 |
| 03 | 00000011 | 3 |
| 04 | 00000100 | 4 |
| 05 | 00000101 | 5 |
| 06 | 00000110 | 6 |
| 07 | 00000111 | 7 |
| 08 | 00001000 | 8 |
| 09 | 00001001 | 9 |
| 0A | 00001010 | 10 |
| 0B | 00001011 | 11 |
| 0C | 00001100 | 12 |
| 0D | 00001101 | 13 |
| 0E | 00001110 | 14 |
| 0F | 00001111 | 15 |
| 10 | 00010000 | 16 |
| 11 | 00010001 | 17 |
| 12 | 00010010 | 18 |
| 13 | 00010011 | 19 |
| 14 | 00010100 | 20 |
| 15 | 00010101 | 21 |
| 16 | 00010110 | 22 |
| 17 | 00010111 | 23 |
| 18 | 00011000 | 24 |
| 19 | 00011001 | 25 |
| 1A | 00011010 | 26 |
| 1B | 00011011 | 27 |
| 1C | 00011100 | 28 |
| 1D | 00011101 | 29 |
| 1E | 00011110 | 30 |
| 1F | 00011111 | 31 |
| 20 | 00100000 | 32 |
| 21 | 00100001 | 33 |
| 22 | 00100010 | 34 |
| 23 | 00100011 | 35 |
| 24 | 00100100 | 36 |
| 25 | 00100101 | 37 |
| 26 | 00100110 | 38 |
| 27 | 00100111 | 39 |
| 28 | 00101000 | 40 |
| 29 | 00101001 | 41 |
| 2A | 00101010 | 42 |
| 2B | 00101011 | 43 |
| 2C | 00101100 | 44 |
| 2D | 00101101 | 45 |
| 2E | 00101110 | 46 |
| 2F | 00101111 | 47 |
| 30 | 00110000 | 48 |
| 31 | 00110001 | 49 |
| 32 | 00110010 | 50 |
| 33 | 00110011 | 51 |
| 34 | 00110100 | 52 |
| 35 | 00110101 | 53 |
| 36 | 00110110 | 54 |
| 37 | 00110111 | 55 |
| 38 | 00111000 | 56 |
| 39 | 00111001 | 57 |
| 3A | 00111010 | 58 |
| 3B | 00111011 | 59 |
| 3C | 00111100 | 60 |
| 3D | 00111101 | 61 |
| 3E | 00111110 | 62 |
| 3F | 00111111 | 63 |
| Hex | Binary | Dec |
|---|---|---|
| 40 | 01000000 | 64 |
| 41 | 01000001 | 65 |
| 42 | 01000010 | 66 |
| 43 | 01000011 | 67 |
| 44 | 01000100 | 68 |
| 45 | 01000101 | 69 |
| 46 | 01000110 | 70 |
| 47 | 01000111 | 71 |
| 48 | 01001000 | 72 |
| 49 | 01001001 | 73 |
| 4A | 01001010 | 74 |
| 4B | 01001011 | 75 |
| 4C | 01001100 | 76 |
| 4D | 01001101 | 77 |
| 4E | 01001110 | 78 |
| 4F | 01001111 | 79 |
| 50 | 01010000 | 80 |
| 51 | 01010001 | 81 |
| 52 | 01010010 | 82 |
| 53 | 01010011 | 83 |
| 54 | 01010100 | 84 |
| 55 | 01010101 | 85 |
| 56 | 01010110 | 86 |
| 57 | 01010111 | 87 |
| 58 | 01011000 | 88 |
| 59 | 01011001 | 89 |
| 5A | 01011010 | 90 |
| 5B | 01011011 | 91 |
| 5C | 01011100 | 92 |
| 5D | 01011101 | 93 |
| 5E | 01011110 | 94 |
| 5F | 01011111 | 95 |
| 60 | 01100000 | 96 |
| 61 | 01100001 | 97 |
| 62 | 01100010 | 98 |
| 63 | 01100011 | 99 |
| 64 | 01100100 | 100 |
| 65 | 01100101 | 101 |
| 66 | 01100110 | 102 |
| 67 | 01100111 | 103 |
| 68 | 01101000 | 104 |
| 69 | 01101001 | 105 |
| 6A | 01101010 | 106 |
| 6B | 01101011 | 107 |
| 6C | 01101100 | 108 |
| 6D | 01101101 | 109 |
| 6E | 01101110 | 110 |
| 6F | 01101111 | 111 |
| 70 | 01110000 | 112 |
| 71 | 01110001 | 113 |
| 72 | 01110010 | 114 |
| 73 | 01110011 | 115 |
| 74 | 01110100 | 116 |
| 75 | 01110101 | 117 |
| 76 | 01110110 | 118 |
| 77 | 01110111 | 119 |
| 78 | 01111000 | 120 |
| 79 | 01111001 | 121 |
| 7A | 01111010 | 122 |
| 7B | 01111011 | 123 |
| 7C | 01111100 | 124 |
| 7D | 01111101 | 125 |
| 7E | 01111110 | 126 |
| 7F | 01111111 | 127 |
| Hex | Binary | Dec |
|---|---|---|
| 80 | 10000000 | 128 |
| 81 | 10000001 | 129 |
| 82 | 10000010 | 130 |
| 83 | 10000011 | 131 |
| 84 | 10000100 | 132 |
| 85 | 10000101 | 133 |
| 86 | 10000110 | 134 |
| 87 | 10000111 | 135 |
| 88 | 10001000 | 136 |
| 89 | 10001001 | 137 |
| 8A | 10001010 | 138 |
| 8B | 10001011 | 139 |
| 8C | 10001100 | 140 |
| 8D | 10001101 | 141 |
| 8E | 10001110 | 142 |
| 8F | 10001111 | 143 |
| 90 | 10010000 | 144 |
| 91 | 10010001 | 145 |
| 92 | 10010010 | 146 |
| 93 | 10010011 | 147 |
| 94 | 10010100 | 148 |
| 95 | 10010101 | 149 |
| 96 | 10010110 | 150 |
| 97 | 10010111 | 151 |
| 98 | 10011000 | 152 |
| 99 | 10011001 | 153 |
| 9A | 10011010 | 154 |
| 9B | 10011011 | 155 |
| 9C | 10011100 | 156 |
| 9D | 10011101 | 157 |
| 9E | 10011110 | 158 |
| 9F | 10011111 | 159 |
| A0 | 10100000 | 160 |
| A1 | 10100001 | 161 |
| A2 | 10100010 | 162 |
| A3 | 10100011 | 163 |
| A4 | 10100100 | 164 |
| A5 | 10100101 | 165 |
| A6 | 10100110 | 166 |
| A7 | 10100111 | 167 |
| A8 | 10101000 | 168 |
| A9 | 10101001 | 169 |
| AA | 10101010 | 170 |
| AB | 10101011 | 171 |
| AC | 10101100 | 172 |
| AD | 10101101 | 173 |
| AE | 10101110 | 174 |
| AF | 10101111 | 175 |
| B0 | 10110000 | 176 |
| B1 | 10110001 | 177 |
| B2 | 10110010 | 178 |
| B3 | 10110011 | 179 |
| B4 | 10110100 | 180 |
| B5 | 10110101 | 181 |
| B6 | 10110110 | 182 |
| B7 | 10110111 | 183 |
| B8 | 10111000 | 184 |
| B9 | 10111001 | 185 |
| BA | 10111010 | 186 |
| BB | 10111011 | 187 |
| BC | 10111100 | 188 |
| BD | 10111101 | 189 |
| BE | 10111110 | 190 |
| BF | 10111111 | 191 |
| Hex | Binary | Dec |
|---|---|---|
| C0 | 11000000 | 192 |
| C1 | 11000001 | 193 |
| C2 | 11000010 | 194 |
| C3 | 11000011 | 195 |
| C4 | 11000100 | 196 |
| C5 | 11000101 | 197 |
| C6 | 11000110 | 198 |
| C7 | 11000111 | 199 |
| C8 | 11001000 | 200 |
| C9 | 11001001 | 201 |
| CA | 11001010 | 202 |
| CB | 11001011 | 203 |
| CC | 11001100 | 204 |
| CD | 11001101 | 205 |
| CE | 11001110 | 206 |
| CF | 11001111 | 207 |
| D0 | 11010000 | 208 |
| D1 | 11010001 | 209 |
| D2 | 11010010 | 210 |
| D3 | 11010011 | 211 |
| D4 | 11010100 | 212 |
| D5 | 11010101 | 213 |
| D6 | 11010110 | 214 |
| D7 | 11010111 | 215 |
| D8 | 11011000 | 216 |
| D9 | 11011001 | 217 |
| DA | 11011010 | 218 |
| DB | 11011011 | 219 |
| DC | 11011100 | 220 |
| DD | 11011101 | 221 |
| DE | 11011110 | 222 |
| DF | 11011111 | 223 |
| E0 | 11100000 | 224 |
| E1 | 11100001 | 225 |
| E2 | 11100010 | 226 |
| E3 | 11100011 | 227 |
| E4 | 11100100 | 228 |
| E5 | 11100101 | 229 |
| E6 | 11100110 | 230 |
| E7 | 11100111 | 231 |
| E8 | 11101000 | 232 |
| E9 | 11101001 | 233 |
| EA | 11101010 | 234 |
| EB | 11101011 | 235 |
| EC | 11101100 | 236 |
| ED | 11101101 | 237 |
| EE | 11101110 | 238 |
| EF | 11101111 | 239 |
| F0 | 11110000 | 240 |
| F1 | 11110001 | 241 |
| F2 | 11110010 | 242 |
| F3 | 11110011 | 243 |
| F4 | 11110100 | 244 |
| F5 | 11110101 | 245 |
| F6 | 11110110 | 246 |
| F7 | 11110111 | 247 |
| F8 | 11111000 | 248 |
| F9 | 11111001 | 249 |
| FA | 11111010 | 250 |
| FB | 11111011 | 251 |
| FC | 11111100 | 252 |
| FD | 11111101 | 253 |
| FE | 11111110 | 254 |
| FF | 11111111 | 255 |
For a table in decimal only, see the hex to decimal table.
Practice problems
Convert these hex values to binary by hand, then check each answer with the converter above or the quiz below.
- Convert 4B to binary.
- Convert 9F to binary.
- Convert 100 to binary.
- Convert C0FFEE to binary.
- Convert binary 10110011 to hex.
- How many bytes is hex ABCDEF01?
Answers:
- 4B = 01001011 (4 → 0100, B → 1011).
- 9F = 10011111 (9 → 1001, F → 1111).
- 100 = 100000000 (1 → 0001, 0 → 0000, 0 → 0000; drop the leading zeros to get 9 bits).
- C0FFEE = 110000001111111111101110 (C → 1100, 0 → 0000, F → 1111, F → 1111, E → 1110, E → 1110).
- 10110011 splits into 1011 and 0011, which is B3.
- ABCDEF01 has 8 hex digits, so 8 × 4 = 32 bits, which is 4 bytes.
Frequently asked questions
How do you convert hex to binary?
How do you convert binary to hex?
Why does one hex digit equal 4 bits?
What is a nibble?
What is 0xFF in binary?
What is 0x00 in binary?
How many bits is a hex digit?
Can hex have fractions in binary?
What are bitwise operations in hex?
Related tools
- Hex to decimal converter: convert hex to decimal with digit-by-digit steps.
- Decimal to hex converter: convert decimal to hex with the division method.
- Hex to octal converter: convert hex to base 8.
- Signed hex to decimal: convert two’s complement hex values.
- Bulk hex to decimal: convert a list of values at once.
- Hex to decimal table: the full 0–FF reference chart.