Hex to Binary Converter

This hex to binary converter transforms hexadecimal (base-16) numbers into binary (base-2) representation. Each hex digit maps to exactly 4 binary bits. Enter any hex value to see its binary equivalent with a step-by-step nibble-by-nibble breakdown.

Hex to Binary Converter

Convert hexadecimal numbers to their binary representation

Frequently Asked Questions

How do you convert hex to binary?

Replace each hexadecimal 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 converts to binary by replacing 2 with 0010 and F with 1111, giving 00101111. This direct substitution works because each hex digit represents exactly 4 binary bits (since 16 = 2^4).

What is hexadecimal?

Hexadecimal (hex) is a base-16 number system that uses sixteen symbols: digits 0-9 for values zero through nine, and letters A-F for values ten through fifteen. It is widely used in computing because each hex digit maps perfectly to 4 binary bits, making it a compact and human-readable way to represent binary data. Two hex digits represent one byte (8 bits), so a byte value like 11111111 can be written simply as FF.

Why does each hex digit equal 4 binary bits?

Each hex digit equals 4 binary bits because 16 = 2^4. A single hex digit can represent values 0-15, which is exactly the range of 4 binary bits (0000 to 1111). This perfect power-of-2 relationship means conversion between hex and binary is a simple direct substitution without any arithmetic. This is why hexadecimal became the preferred shorthand for binary in computing, rather than decimal or octal.

What is 0xFF in binary?

0xFF in binary is 11111111 (eight 1s). The 0x prefix indicates a hexadecimal number. F in hex equals 15 in decimal, which is 1111 in binary. Since FF has two hex digits, each converting to 4 bits, the result is 1111 1111 = 11111111. This equals 255 in decimal and represents the maximum value of an unsigned 8-bit byte. 0xFF is commonly used in programming as a bitmask to isolate a single byte.

Where is hexadecimal used?

Hexadecimal is used extensively in computing: color codes in web design (#FF5733), memory addresses in debugging (0x7FFF5FBFF8AC), MAC addresses in networking (00:1A:2B:3C:4D:5E), Unicode character codes (U+0041 for 'A'), cryptographic hashes (SHA-256), and assembly language programming. It is preferred because it provides a compact, human-readable representation of binary data where two hex digits represent exactly one byte.

How do you convert binary to hex?

Group the binary number into sets of 4 bits, starting from the right. Pad the leftmost group with leading zeros if needed. Then replace each 4-bit group with its hex equivalent: 0000=0, 0001=1, ..., 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. For example, binary 11010110 groups as 1101 0110, converting to hex D6.

What are the hex digits A through F?

The hex digits A through F represent decimal values 10 through 15: A=10 (1010 in binary), B=11 (1011), C=12 (1100), D=13 (1101), E=14 (1110), F=15 (1111). Letters are used because each hex position must represent 16 possible values (0-15), which exceeds the ten decimal digits available. Both uppercase (A-F) and lowercase (a-f) are accepted in most contexts, though uppercase is conventional.

How do you convert binary back to hex?

Group the binary digits into sets of 4 from right to left, then convert each group to its hex equivalent. For example, 10110010 becomes 1011 0010, which is B2 in hexadecimal.

How to Convert Hex to Binary

Converting hexadecimal to binary is one of the most straightforward base conversions in computing. Because hexadecimal is base-16 and binary is base-2, and because 16 is a perfect power of 2 (16 = 24), every single hex digit maps directly to exactly 4 binary bits. No arithmetic is needed — just a simple lookup and substitution.

Step-by-Step Conversion Method

Follow these steps to convert any hexadecimal number to binary by hand:

Step 1: Write down the hex number

Remove any prefix such as 0x or #. For example, 0x2F becomes 2F.

Step 2: Replace each hex digit with its 4-bit binary equivalent

Use the mapping table: 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 3: Combine all 4-bit groups

Concatenate the binary groups from left to right. The result is the full binary representation.

Why Each Hex Digit Equals 4 Binary Bits

The mathematical relationship is simple: a single hexadecimal digit can represent values from 0 to 15, which is exactly the range of 4 binary bits (24=162^4 = 16). This means:

(d)16=(b3b2b1b0)2where d{0,1,...,F}(d)_{16} = (b_3 b_2 b_1 b_0)_2 \quad \text{where } d \in \{0,1,...,F\}

Each hex digit dd maps to exactly one 4-bit binary nibble. This perfect power-of-2 relationship is why hexadecimal became the preferred shorthand for binary data in computing, rather than decimal or octal.

Two hex digits represent one byte (8 bits), four hex digits represent a 16-bit word, and eight hex digits represent a 32-bit word. This clean alignment makes hex-to-binary conversion trivially mechanical.

Hex to Binary Conversion Examples

Below are worked examples showing the hex to binary conversion process step by step, from simple single-byte values to multi-byte color codes.

Convert 2F to Binary

Hex input: 2F

1. 216=(0010)22_{16} = (0010)_2

2. F16=(1111)2F_{16} = (1111)_2

3. 2F16=(0010  1111)22F_{16} = (0010\;1111)_2

Decimal equivalent: 47

Convert 4FA to Binary

Hex input: 4FA

1. 416=(0100)24_{16} = (0100)_2

2. F16=(1111)2F_{16} = (1111)_2

3. A16=(1010)2A_{16} = (1010)_2

4. 4FA16=(0100  1111  1010)24FA_{16} = (0100\;1111\;1010)_2

Decimal equivalent: 1,274

Convert FF to Binary

Hex input: FF

1. F16=(1111)2F_{16} = (1111)_2

2. F16=(1111)2F_{16} = (1111)_2

3. FF16=(1111  1111)2FF_{16} = (1111\;1111)_2

Decimal equivalent: 255 — the maximum value of a single unsigned byte (8 bits all set to 1).

Convert Color Code #3A7BD5 to Binary

Hex input: #3A7BD5 (a shade of blue)

1. 316=(0011)23_{16} = (0011)_2

2. A16=(1010)2A_{16} = (1010)_2

3. 716=(0111)27_{16} = (0111)_2

4. B16=(1011)2B_{16} = (1011)_2

5. D16=(1101)2D_{16} = (1101)_2

6. 516=(0101)25_{16} = (0101)_2

7. 3A7BD516=(0011  1010  0111  1011  1101  0101)23A7BD5_{16} = (0011\;1010\;0111\;1011\;1101\;0101)_2

The 24-bit result breaks into three bytes: R=00111010 (58), G=01111011 (123), B=11010101 (213). You can also convert hex color codes using our hex to RGB converter.

Hex to Binary Conversion Table

This complete hex to binary conversion table covers all 256 byte values from 00 to FF. Each row shows the hexadecimal value, its decimal equivalent, and the 8-bit binary representation.

Quick Reference (Single Hex Digits 0-F):

HexDecimalBinary
00000000000
01100000001
02200000010
03300000011
04400000100
05500000101
06600000110
07700000111
08800001000
09900001001
0A1000001010
0B1100001011
0C1200001100
0D1300001101
0E1400001110
0F1500001111

This table covers all possible single-byte hexadecimal values (00-FF) with their decimal and 8-bit binary equivalents. For values beyond FF, simply apply the same 4-bit substitution to each hex digit.

Hex to Binary in Programming

Most programming languages provide built-in functions for converting between hexadecimal and binary. Here are examples in the three most popular languages.

Python

# Convert hex string to binary string
hex_value = "FF"
binary_value = bin(int(hex_value, 16))
print(binary_value)          # '0b11111111'

# Remove '0b' prefix and pad to 8 bits
binary_clean = bin(int(hex_value, 16))[2:].zfill(8)
print(binary_clean)          # '11111111'

# Format with 4-bit groups
hex_value = "3A7BD5"
binary_str = bin(int(hex_value, 16))[2:].zfill(len(hex_value) * 4)
grouped = ' '.join([binary_str[i:i+4] for i in range(0, len(binary_str), 4)])
print(grouped)               # '0011 1010 0111 1011 1101 0101'

JavaScript

// Convert hex string to binary string
const hexValue = "FF";
const binaryValue = parseInt(hexValue, 16).toString(2);
console.log(binaryValue);    // '11111111'

// Pad to 8 bits
const padded = binaryValue.padStart(8, '0');
console.log(padded);         // '11111111'

// For large hex values, use BigInt
const bigHex = "3A7BD5";
const bigBin = BigInt("0x" + bigHex).toString(2).padStart(bigHex.length * 4, '0');
console.log(bigBin);         // '001110100111101111010101'

Java

// Convert hex string to binary string
String hexValue = "FF";
String binaryValue = Integer.toBinaryString(Integer.parseInt(hexValue, 16));
System.out.println(binaryValue);  // "11111111"

// Pad to 8 bits
String padded = String.format("%8s", binaryValue).replace(' ', '0');
System.out.println(padded);       // "11111111"

// For larger values, use Long
String bigHex = "3A7BD5";
String bigBin = Long.toBinaryString(Long.parseLong(bigHex, 16));
System.out.println(bigBin);       // "1110100111101111010101"

Key Features

  • Instant hex to binary conversion with real-time validation
  • Comprehensive hex to binary conversion process visualization
  • Clear error messages for invalid hexadecimal inputs
  • Optional digit grouping for enhanced binary number readability
  • Support for converting any length of hexadecimal numbers to binary
  • Automatic decimal equivalent display with smart formatting
  • Step-by-step hex to binary conversion breakdown

Applications

  • Digital circuit design and analysis requiring hex to binary conversions
  • Computer memory debugging using hex to binary representation
  • Binary data manipulation in programming with hex to binary conversion
  • Assembly language programming and machine code analysis
  • Educational purposes for understanding hex to binary number systems
  • Color code conversions in web development (e.g., hex to RGB)

Related Converters

Explore our other number system and encoding converters for related tasks:

For a deep dive into the theory and practice of hex-to-binary conversion, read our comprehensive guide: Hex to Binary Conversion: Complete Guide with Table & Examples.

Related Tools