How to Convert Hexadecimal Numbers

Hexadecimal (base-16) is the standard compact representation for binary data in computing. It is everywhere: memory addresses in a debugger, color codes in CSS (#FF5733), SHA-256 hashes in security certificates, IPv4 addresses in routing tables, and ASCII values in character encoding references. One hex digit represents exactly 4 binary bits, so one byte (8 bits) is always exactly two hex digits — a perfect fit. This guide covers all three conversion paths out of hexadecimal with detailed worked examples, a complete digit reference table, and practical real-world applications.

The 16 Hex Digits — Complete Reference Table

Hexadecimal extends the familiar 0–9 digits with six letters A through F, representing the values 10–15 that have no single-character decimal symbol. Every hex digit maps to a unique 4-bit binary pattern — the relationship is exact and fixed. Learn this table and every hex conversion becomes a lookup rather than a calculation.

HexDecimal4-bit BinaryHexDecimal4-bit Binary
000000881000
110001991001
220010A101010
330011B111011
440100C121100
550101D131101
660110E141110
770111F151111

Hex → Decimal: Positional Notation

Replace each hex letter with its decimal value (A=10 through F=15), then multiply each digit by 16 raised to its positional power (rightmost = position 0), and sum all the products.

  1. Write the hex number and label each digit's position from 0 (rightmost) to n−1 (leftmost).
  2. Replace A→10, B→11, C→12, D→13, E→14, F→15. Digits 0–9 stay as-is.
  3. Multiply each digit value by 16^position.
  4. Add all products — the total is the decimal equivalent.

Worked Example 1 — Convert (1A)₁₆ to Decimal

(1A)₁₆ = 26₁₀. Verify: 26 ÷ 16 = 1 R 10(=A), 1 ÷ 16 = 0 R 1 → read bottom to top: 1A₁₆ ✓

Worked Example 2 — Convert (ABF3)₁₆ to Decimal

A four-digit hex number. Replace A=10, B=11, F=15 and apply positional weights.

Hex digitABF3
Decimal value1011153
Position3210
Positional power16³=409616²=25616¹=1616⁰=1
Product4096028162403
(ABF3)₁₆ = 44019₁₀

Hex → Binary: Direct 4-Bit Substitution

Since 2⁴ = 16, every hex digit maps to exactly 4 binary bits — the table above. This is the fastest conversion in number systems: no arithmetic whatsoever. Just replace each hex digit with its 4-bit binary string from the table, left to right, and concatenate.

Worked Example — Convert (ABF3)₁₆ to Binary

Hex digitABF3
4-bit binary1010101111110011
(ABF3)₁₆ = (1010 1011 1111 0011)₂ = (1010101111110011)₂. That is 16 bits — exactly 4 bits per hex digit, every time.

Worked Example — Convert (FF)₁₆ to Binary

Hex digitFF
4-bit binary11111111
(FF)₁₆ = (11111111)₂ = 255₁₀ — all 8 bits of a byte set to 1. This is the maximum value one byte can hold.

Hex → Octal: Via Binary

There is no direct hex-to-octal table (16 and 8 don't share a simple power relationship), so binary serves as the bridge. Expand each hex digit to 4 bits, concatenate, then regroup into 3-bit chunks from right to left (padding the leftmost group with zeros if necessary), and convert each 3-bit group to an octal digit.

  1. Replace each hex digit with its 4-bit binary equivalent.
  2. Concatenate all bits into one binary string.
  3. Pad the leftmost end with zeros until the length is a multiple of 3.
  4. Split into 3-bit groups from right to left.
  5. Convert each 3-bit group to an octal digit (0–7).

Worked Example — Convert (FC)₁₆ to Octal

Step 1: F=1111, C=1100 → binary string 11111100 (8 bits). Step 2: pad to 9 bits → 011111100. Step 3: groups of 3: 011 | 111 | 100.

3-bit group011111100
Octal digit374
(FC)₁₆ = (374)₈. Verify: 3×64 + 7×8 + 4 = 192+56+4 = 252₁₀. And F×16 + C = 15×16 + 12 = 252₁₀ ✓

Real-World Hexadecimal — Where You See It

ContextExampleDecoded meaning
CSS web color#FF5733R=255, G=87, B=51 (a warm red-orange)
ASCII letter 'A'0x41Decimal 65 → binary 01000001
Max 1 byte0xFFDecimal 255 → all 8 bits set: 11111111
IPv4 loopback0x7F000001127.0.0.1 — 4 bytes, each pair is one octet
SHA-256 constant0x6a09e667First of eight initial hash values
💡To decode a web color like #3498DB: split into R=34, G=98, B=DB. Then 34₁₆=52, 98₁₆=152, DB₁₆=219 → RGB(52, 152, 219) — a medium blue. Every pair of hex digits is one color channel (0–255).

Frequently Asked Questions

Are hex digits A–F case-sensitive?

No. 'A' and 'a' represent exactly the same value (10). Uppercase is conventional in hardware documentation, memory dumps, and assembly language. Lowercase is common in CSS colors (#ff5733) and cryptographic hashes. Both are fully equivalent — this converter accepts either.

Why does 0xFF mean 255?

FF in hex means F (15) at position 1 and F (15) at position 0. Expanding: 15×16 + 15 = 240 + 15 = 255. In binary, FF = 11111111 — all eight bits of one byte are set to 1. This is the maximum value that fits in a single byte, which is why you see FF so often in color codes, network masks (255.255.255.0), and memory initialization.

How do I decode a hex color code like #3498DB?

Split the 6 characters into three 2-digit pairs: R=34, G=98, B=DB. Convert each pair independently: 34₁₆ = 3×16+4 = 52, 98₁₆ = 9×16+8 = 152, DB₁₆ = 13×16+11 = 219. So #3498DB is RGB(52, 152, 219) — a medium blue.

What does the 0x prefix mean before a hex number?

0x is the standard C-language prefix indicating a hexadecimal literal, adopted by most programming languages (Java, JavaScript, Python, Rust, Go, etc.). For example, 0xFF means the hex value FF = decimal 255. Other notations you may see: FFh or FFH (assembly language), FF₁₆ (mathematics), and #FF (CSS colors).