Hex to Decimal

Hex to binary converter

Type a hex value to see its binary form, bit by bit. Each hex digit splits into exactly four bits, and two digits make one byte. The sections below cover the method, a nibble chart, worked examples, the full 00–FF table, bytes and bit widths, code in six languages and common questions.

One hex digit, four bits tap a bit to flip it

Decimal
Size
Bits set

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.

HexBinaryDecimal
000000
100011
200102
300113
401004
501015
601106
701117
HexBinaryDecimal
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115

How to convert hex to binary

Step-by-step method

  1. Write the hex number with each digit separated.
  2. Replace each digit with its 4-bit pattern from the nibble chart.
  3. Join the 4-bit groups in the same left-to-right order.
  4. 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 digitDEADBEEF
Binary11011110101011011011111011101111

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 digitsBitsBytesRange (unsigned)
14½ (nibble)0–15
2810–255
41620–65,535
83240–4,294,967,295
166480–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:

  1. 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.
  2. 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.
  3. 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 string

Python’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

LanguageHex to binaryExampleResult
JavaInteger.toBinaryString()Integer.toBinaryString(0x3C)"111100"
Excel=HEX2BIN()=HEX2BIN("3C", 8)"00111100"
Bashbcecho "obase=2;ibase=16;3C" | bc111100

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

HexBinaryDecimalWhere you meet it
00000000000Null byte, zero flag
0F0000111115Low-nibble mask
3C0011110060ASCII less-than sign (<)
550101010185Alternating-bit test pattern
7F01111111127Largest signed 8-bit integer
8010000000128Smallest signed 8-bit integer (−128 in two’s complement)
AA10101010170Alternating-bit test pattern
F011110000240High-nibble mask
FF11111111255Largest unsigned byte, all bits set

Full table

HexBinaryDec
00000000000
01000000011
02000000102
03000000113
04000001004
05000001015
06000001106
07000001117
08000010008
09000010019
0A0000101010
0B0000101111
0C0000110012
0D0000110113
0E0000111014
0F0000111115
100001000016
110001000117
120001001018
130001001119
140001010020
150001010121
160001011022
170001011123
180001100024
190001100125
1A0001101026
1B0001101127
1C0001110028
1D0001110129
1E0001111030
1F0001111131
200010000032
210010000133
220010001034
230010001135
240010010036
250010010137
260010011038
270010011139
280010100040
290010100141
2A0010101042
2B0010101143
2C0010110044
2D0010110145
2E0010111046
2F0010111147
300011000048
310011000149
320011001050
330011001151
340011010052
350011010153
360011011054
370011011155
380011100056
390011100157
3A0011101058
3B0011101159
3C0011110060
3D0011110161
3E0011111062
3F0011111163
HexBinaryDec
400100000064
410100000165
420100001066
430100001167
440100010068
450100010169
460100011070
470100011171
480100100072
490100100173
4A0100101074
4B0100101175
4C0100110076
4D0100110177
4E0100111078
4F0100111179
500101000080
510101000181
520101001082
530101001183
540101010084
550101010185
560101011086
570101011187
580101100088
590101100189
5A0101101090
5B0101101191
5C0101110092
5D0101110193
5E0101111094
5F0101111195
600110000096
610110000197
620110001098
630110001199
6401100100100
6501100101101
6601100110102
6701100111103
6801101000104
6901101001105
6A01101010106
6B01101011107
6C01101100108
6D01101101109
6E01101110110
6F01101111111
7001110000112
7101110001113
7201110010114
7301110011115
7401110100116
7501110101117
7601110110118
7701110111119
7801111000120
7901111001121
7A01111010122
7B01111011123
7C01111100124
7D01111101125
7E01111110126
7F01111111127
HexBinaryDec
8010000000128
8110000001129
8210000010130
8310000011131
8410000100132
8510000101133
8610000110134
8710000111135
8810001000136
8910001001137
8A10001010138
8B10001011139
8C10001100140
8D10001101141
8E10001110142
8F10001111143
9010010000144
9110010001145
9210010010146
9310010011147
9410010100148
9510010101149
9610010110150
9710010111151
9810011000152
9910011001153
9A10011010154
9B10011011155
9C10011100156
9D10011101157
9E10011110158
9F10011111159
A010100000160
A110100001161
A210100010162
A310100011163
A410100100164
A510100101165
A610100110166
A710100111167
A810101000168
A910101001169
AA10101010170
AB10101011171
AC10101100172
AD10101101173
AE10101110174
AF10101111175
B010110000176
B110110001177
B210110010178
B310110011179
B410110100180
B510110101181
B610110110182
B710110111183
B810111000184
B910111001185
BA10111010186
BB10111011187
BC10111100188
BD10111101189
BE10111110190
BF10111111191
HexBinaryDec
C011000000192
C111000001193
C211000010194
C311000011195
C411000100196
C511000101197
C611000110198
C711000111199
C811001000200
C911001001201
CA11001010202
CB11001011203
CC11001100204
CD11001101205
CE11001110206
CF11001111207
D011010000208
D111010001209
D211010010210
D311010011211
D411010100212
D511010101213
D611010110214
D711010111215
D811011000216
D911011001217
DA11011010218
DB11011011219
DC11011100220
DD11011101221
DE11011110222
DF11011111223
E011100000224
E111100001225
E211100010226
E311100011227
E411100100228
E511100101229
E611100110230
E711100111231
E811101000232
E911101001233
EA11101010234
EB11101011235
EC11101100236
ED11101101237
EE11101110238
EF11101111239
F011110000240
F111110001241
F211110010242
F311110011243
F411110100244
F511110101245
F611110110246
F711110111247
F811111000248
F911111001249
FA11111010250
FB11111011251
FC11111100252
FD11111101253
FE11111110254
FF11111111255

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.

  1. Convert 4B to binary.
  2. Convert 9F to binary.
  3. Convert 100 to binary.
  4. Convert C0FFEE to binary.
  5. Convert binary 10110011 to hex.
  6. How many bytes is hex ABCDEF01?

Answers:

  1. 4B = 01001011 (4 → 0100, B → 1011).
  2. 9F = 10011111 (9 → 1001, F → 1111).
  3. 100 = 100000000 (1 → 0001, 0 → 0000, 0 → 0000; drop the leading zeros to get 9 bits).
  4. C0FFEE = 110000001111111111101110 (C → 1100, 0 → 0000, F → 1111, F → 1111, E → 1110, E → 1110).
  5. 10110011 splits into 1011 and 0011, which is B3.
  6. ABCDEF01 has 8 hex digits, so 8 × 4 = 32 bits, which is 4 bytes.

Frequently asked questions

How do you convert hex to binary?
Replace each hex digit with its 4-bit binary pattern and join the groups in order. No arithmetic is needed because 16 = 2⁴. Use the nibble chart: 0 = 0000, 1 = 0001, up to F = 1111.
How do you 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 in the nibble chart. For example, 11010110 splits into 1101 and 0110, which gives D6.
Why does one hex digit equal 4 bits?
A hex digit has 16 possible values, and 4 bits also have 16 combinations (2⁴ = 16), so the two systems line up exactly. That is why hex to binary conversion never needs division or multiplication.
What is a nibble?
A nibble is a group of 4 bits, which is half a byte. One hex digit stands for one nibble. The name is a pun on “bite”, and the nibble chart maps every hex digit to its 4-bit pattern.
What is 0xFF in binary?
0xFF = 11111111. All 8 bits are set, which gives the decimal value 255. FF is the largest value one byte can hold. It appears in subnet masks (255.255.255.0), colour channels (#FF means full intensity) and maximum unsigned 8-bit values.
What is 0x00 in binary?
0x00 = 00000000. All 8 bits are cleared. The null byte (0x00) ends strings in C and appears as a zero flag in processor status registers.
How many bits is a hex digit?
Each hex digit stands for exactly 4 bits (one nibble). Two hex digits make 8 bits (one byte), four make 16 bits, eight make 32 bits and sixteen make 64 bits.
Can hex have fractions in binary?
Yes. Hex digits after the point convert the same way: each digit becomes 4 bits after the binary point. Hex 0.8 = binary 0.1000, and hex 0.C = binary 0.1100. For fraction conversion with steps, use the decimal to hex converter.
What are bitwise operations in hex?
Bitwise operations (AND, OR, XOR, NOT and shifts) work on individual bits, and programmers write the operands in hex because each digit maps to 4 bits. For example, 0xF0 AND 0x3C = 0x30, which is 11110000 AND 00111100 = 00110000 in binary. The hex form shows the nibble-level result at a glance.