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 = 2⁴), 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

A single hexadecimal digit can represent values from 0 to 15, which is exactly the range of 4 binary bits (2⁴ = 16). This means each hex digit d 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

  • 2 → 0010
  • F → 1111
  • 2F = 0010 1111 (decimal: 47)

Convert 4FA to Binary

  • 4 → 0100
  • F → 1111
  • A → 1010
  • 4FA = 0100 1111 1010 (decimal: 1,274)

Convert FF to Binary

  • F → 1111
  • F → 1111
  • FF = 1111 1111 (decimal: 255 — the maximum value of a single unsigned byte, all 8 bits set to 1)

Convert Color Code #3A7BD5 to Binary

  • 3 → 0011
  • A → 1010
  • 7 → 0111
  • B → 1011
  • D → 1101
  • 5 → 0101
  • 3A7BD5 = 0011 1010 0111 1011 1101 0101

The 24-bit result breaks into three bytes: R=00111010 (58), G=01111011 (123), B=11010101 (213).

Hex to Binary Conversion Table (Single Digits 0–F)

HexDecimalBinary (4-bit)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

This table covers all 16 single hex digits. For multi-byte values (00–FF), apply the same 4-bit substitution to each hex digit in sequence. The full 256-entry table (00–FF) is available interactively in the converter above.

Hex to Binary in Programming

Most programming languages provide built-in functions for converting between hexadecimal and binary.

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"

Applications

  • Digital circuit design and analysis requiring hex to binary conversions
  • Computer memory debugging using hex to binary representation
  • Binary data manipulation in programming
  • Assembly language programming and machine code analysis
  • Color code conversions in web development
  • Educational purposes for understanding number systems

Related Tools