Converters

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.

Published March 18, 2026
15 minute read
Cryptography Guide

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 DigitDecimal Value
00
11
22
33
44
55
66
77
88
99
A10
B11
C12
D13
E14
F15

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:

HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

Step 1: Write Down the Hex Number

Remove any prefix or notation. Common prefixes include:

  • 0x (C, Java, Python, JavaScript): 0xFF becomes FF
  • # (CSS color codes): #3A7BD5 becomes 3A7BD5
  • $ (6502 assembly): $FF becomes FF
  • h suffix (Intel assembly): FFh becomes FF

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:

HexDecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Extended Examples for Multi-Digit Values

HexDecimalBinary
0000000 0000
0F150000 1111
10160001 0000
7F1270111 1111
801281000 0000
FF2551111 1111
1002560001 0000 0000
FFFF655351111 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:

  1. Group into 4-bit nibbles from right to left. Start at the least significant (rightmost) bit and form groups of four.
  2. Pad with leading zeros if needed. If the leftmost group has fewer than 4 bits, add zeros on the left.
  3. 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:

Python15 lines
Highlighting code...

JavaScript

JavaScript uses parseInt() for hex parsing and .toString(2) for binary output:

JavaScript13 lines
Highlighting code...

Java

Java provides Integer.parseInt() and Integer.toBinaryString():

Java14 lines
Highlighting code...

C/C++

C and C++ use strtol() or direct bitwise operations:

C22 lines
Highlighting code...
509 chars

Common Hex Values Every Developer Should Know

Boundary Values

HexBinaryDecimalSignificance
0x000000 00000Null byte, minimum byte value
0x7F0111 1111127Max signed 8-bit integer
0x801000 0000128Min signed 8-bit (two's comp.)
0xFF1111 1111255Max unsigned 8-bit (1 byte)
0xFFFF1111 1111 1111 111165,535Max unsigned 16-bit
0xFFFFFFFF1111 1111 1111 1111 1111 1111 1111 11114,294,967,295Max unsigned 32-bit

Web Color Values

HexBinaryColor
#0000000000 0000 0000 0000 0000 0000Black
#FFFFFF1111 1111 1111 1111 1111 1111White
#FF00001111 1111 0000 0000 0000 0000Red
#00FF000000 0000 1111 1111 0000 0000Green
#0000FF0000 0000 0000 0000 1111 1111Blue
#FF57331111 1111 0101 0111 0011 0011Orange
#3A7BD50011 1010 0111 1011 1101 0101Blue

ASCII Codes in Hex

HexBinaryCharacter
0x200010 0000Space
0x300011 0000'0'
0x410100 0001'A'
0x610110 0001'a'
0x7E0111 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's parseInt(x, 16).toString(2), Java's Integer.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.

About This Article

This article is part of our comprehensive converters cipher tutorial series. Learn more about classical cryptography and explore our interactive cipher tools.

Try Converters Cipher Tool

Put your knowledge into practice with our interactive convertersencryption and decryption tool.

Try Converters Tool