Hex Calculator: How to Convert Hex, Decimal, and Binary (With Examples)

Hexadecimal turns up everywhere in computing: web colors, memory addresses, error codes, MAC addresses, and file data. A hex calculator lets you convert between hex, decimal, and binary instantly and add or subtract hex values without translating everything by hand.

This guide explains what hex is, how to convert by hand, how to do hex arithmetic, and how to read color codes, with examples you can check yourself.

What Is a Hex Calculator?

A hex calculator works with hexadecimal, the base-16 number system. The free hex calculator can:

  • Convert a value between hexadecimal, decimal, and binary
  • Add and subtract two hexadecimal values

It’s handy for programmers, students, web designers, and anyone debugging low-level data.

What Is Hexadecimal?

Decimal uses 10 digits (0 to 9). Hexadecimal uses 16 symbols: 0 to 9, then A to F for the values 10 to 15.

Hex is popular because one hex digit equals exactly four binary digits (bits). That makes it a compact, readable shorthand for binary data. For example, the 8-bit binary number 10110111 is just B7 in hex.

Hex, Decimal, and Binary Chart

Hex Decimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

Place Values in Hexadecimal

Each position is a power of 16, counting from the right:

Position 4th 3rd 2nd 1st
Value 16³ = 4,096 16² = 256 16¹ = 16 16⁰ = 1

How to Convert Hex to Decimal

Formula: multiply each digit by its place value and add the results.

Example 1: Convert 1A3 to decimal.

  • 1 × 256 = 256
  • A (10) × 16 = 160
  • 3 × 1 = 3
  • Total: 419

Example 2: Convert 7E.

  • 7 × 16 = 112
  • E (14) × 1 = 14
  • Total: 126

Example 3: Convert 3C9.

  • 3 × 256 = 768
  • C (12) × 16 = 192
  • 9 × 1 = 9
  • Total: 969

How to Convert Decimal to Hex

Method: divide by 16 repeatedly, record the remainders, then read them from last to first.

Example 4: Convert 500 to hex.

  • 500 ÷ 16 = 31 remainder 4
  • 31 ÷ 16 = 1 remainder 15 (F)
  • 1 ÷ 16 = 0 remainder 1
  • Read upward: 1F4

Check: 256 + 240 + 4 = 500.

Example 5: Convert 1,000 to hex.

  • 1,000 ÷ 16 = 62 remainder 8
  • 62 ÷ 16 = 3 remainder 14 (E)
  • 3 ÷ 16 = 0 remainder 3
  • Result: 3E8

How to Convert Hex to Binary

Swap each hex digit for its 4-bit group, using the chart above.

Example 6: B7 becomes 1011 + 0111 = 10110111, which equals 183 in decimal (11 × 16 + 7).

How to Convert Binary to Hex

Split the binary number into groups of four bits from the right, then convert each group.

Example 7: 11010110 splits into 1101 and 0110, which is D and 6, so the result is D6 (214 in decimal).

If the leftmost group has fewer than four bits, pad it with zeros on the left.

Hex Arithmetic

Adding Hex Numbers

Example 8: A9 + 5C

Method 1: via decimal. A9 = 169 and 5C = 92. 169 + 92 = 261, which is 105 in hex.

Method 2: digit by digit, carrying at 16.

  • 9 + C (12) = 21 = 16 + 5, so write 5, carry 1
  • A (10) + 5 + 1 = 16, so write 0, carry 1
  • Carry the last 1: 105

Subtracting Hex Numbers

Example 9: F0 − 3A

  • F0 = 240 and 3A = 58
  • 240 − 58 = 182, which is B6 in hex

Multiplying Hex Numbers

Example 10: 1F × 4

  • 1F = 31, and 31 × 4 = 124, which is 7C

Shortcut: multiplying by 10 in hex (16 in decimal) just adds a zero, so 2B × 10 = 2B0, much like multiplying by 10 in decimal.

Hex Color Codes Explained

Web colors use six hex digits in the form #RRGGBB, with two digits each for red, green, and blue. Each pair runs from 00 (0) to FF (255).

Hex Color Red Green Blue Look
#FF0000 255 0 0 Pure red
#FFA500 255 165 0 Orange
#228B22 34 139 34 Forest green
#1E90FF 30 144 255 Bright blue
#808080 128 128 128 Mid gray
#000000 0 0 0 Black
#FFFFFF 255 255 255 White

Example 11: Decode #1E90FF.

  • 1E = 1 × 16 + 14 = 30 (red)
  • 90 = 9 × 16 + 0 = 144 (green)
  • FF = 255 (blue)

So #1E90FF is rgb(30, 144, 255).

Reverse example: rgb(34, 139, 34) becomes 22, 8B, 22, giving #228B22. (139 ÷ 16 = 8 remainder 11, and 11 is B.)

When all three pairs match, such as #808080, you get a shade of gray.

Common Hex Values to Know

Hex Decimal Why It Matters
FF 255 Largest value of one byte
100 256 Number of values in one byte
400 1,024 One kibibyte
7FFF 32,767 Largest signed 16-bit value
FFFF 65,535 Largest unsigned 16-bit value
FFFFFFFF 4,294,967,295 Largest unsigned 32-bit value

Two hex digits equal one byte, and a 32-bit value takes eight hex digits.

Where Hex Is Used

  • Web design: Color codes like #228B22
  • Programming and debugging: Memory addresses, error codes, and bit masks
  • Networking: MAC addresses (12 hex digits) and IPv6 addresses (eight groups of four hex digits)
  • Character encoding: ASCII and Unicode code points. For example, 41 is “A” (65), 61 is “a” (97), 30 is the digit “0” (48), and 20 is a space (32)
  • File inspection: Hex editors show raw file bytes in hex

Hex Notation: Prefixes and Suffixes

Hex values are written in different ways depending on the context:

  • 0x2F: C, C++, Java, JavaScript, Python
  • #FF5733: CSS and HTML colors
  • 2Fh: Assembly and some documentation
  • $2F: Some assembly languages and older systems
  • \x2F: Escape sequences inside strings

The math is the same in all of them. Only the notation changes.

Hex and Negative Numbers

Computers usually store negative integers in two’s complement form. In an 8-bit signed value, FF means −1 and 80 means −128. The same hex digits can mean different numbers depending on whether the value is signed or unsigned, so always check which one your system uses.

Common Mistakes to Avoid

  • Forgetting that A to F stand for 10 to 15
  • Reading hex digits as decimal (10 in hex is 16, not 10)
  • Mixing up place values, which are powers of 16
  • Dropping the leading zeros of binary groups when converting
  • Ignoring whether a value is signed or unsigned
  • Confusing the letter O with the digit 0 when typing hex

FAQ: Hex Calculator

How do you convert hex to decimal?
Multiply each digit by 16 raised to its position, then add the results. For example, 2F = 2 × 16 + 15 = 47.

How do you convert decimal to hex?
Divide by 16 repeatedly, note the remainders, and read them in reverse order.

What is FF in decimal?
255.

Why do programmers use hex instead of binary?
Hex is much shorter and each digit maps to exactly four bits, so it’s easy to read and convert.

What is the hex value of 255?
FF.

Is hex case-sensitive?
No. ff and FF are the same value, though some style guides prefer uppercase.

How do I read a hex color code?
Split it into three pairs for red, green, and blue, then convert each pair to decimal (0 to 255).

Is the hex calculator free?
Yes. The free hex calculator needs no sign-up.

Related Calculators

Final Thoughts

Hexadecimal looks odd at first, but it follows simple rules: 16 symbols, place values that are powers of 16, and a clean link to binary. Once you see that each hex digit is four bits, conversions get much easier. Use the free hex calculator to check your work, and double-check any critical results in programming or engineering projects.

This article is for educational purposes. Verify results independently for programming or engineering work where precision is critical.