Skip to main content
0x

Hex Calculator

Convert between hexadecimal and decimal numbers. Perform hex arithmetic with step-by-step solutions and preview hex color codes.

Hex Output Format

Decimal

255

Hex InputFF
Binary11111111
Bit Length8 bits

Step-by-Step Conversion

  1. 1
    Starting hex value: FF
  2. 2
    Position 0: F (15) x 16^0 (1)= 15
  3. 3
    Position 1: F (15) x 16^1 (16)= 240
  4. 4
    Sum all values: 15 x 1 + 15 x 16= 255

Hexadecimal Arithmetic

Hex to Decimal Reference

A
= 10
B
= 11
C
= 12
D
= 13
E
= 14
F
= 15
FF
= 255
100
= 256

Powers of 16

16^0
1
16^1
16
16^2
256
16^3
4,096
16^4
65,536
16^5
1,048,576

About This Calculator

Need to convert hexadecimal numbers or do hex math? Whether you're a programmer debugging memory addresses, a web designer working with color codes, or a student learning number systems, our free Hexadecimal Calculator makes base-16 math simple and intuitive.

Hexadecimal (base-16) is everywhere in computing. Every color you see on the web is represented by a hex code like #FF5733. Memory addresses, MAC addresses, and error codes are displayed in hex. Programmers work with hex daily when examining binary data, configuring hardware, or debugging low-level code. Yet converting between hex, decimal, and binary by hand is tedious and error-prone.

This calculator instantly converts between hexadecimal, decimal, and binary—no mental math required. Enter a hex value like "1A3F" and see its decimal (6719) and binary (1101000111111) equivalents instantly. Need to add two hex numbers? Just enter them and get your result in hex format. Working with CSS colors? Enter a hex color code and see a live preview of exactly what that color looks like.

Unlike basic calculators, this tool understands hexadecimal notation. You can enter values with or without the "0x" prefix, use uppercase or lowercase letters (A-F or a-f), and even input 6-digit hex color codes with the # prefix. The calculator validates your input in real-time, highlighting invalid characters before you even click calculate. Whether you need quick conversions, hex arithmetic, or color previews, this calculator has you covered—all in your browser, completely free.

How to Use the Hex Calculator

  1. 1**Enter your hexadecimal value**: Type a hex number (0-9, A-F) in the input field. You can include "0x" prefix or leave it off—both work.
  2. 2**View instant conversions**: The calculator automatically shows the decimal and binary equivalents as you type.
  3. 3**Perform hex arithmetic**: Select an operation (Add, Subtract, Multiply) and enter a second hex value to calculate.
  4. 4**Preview hex colors**: Enter a 6-digit hex color code (with or without #) to see a live color preview swatch.
  5. 5**Switch input modes**: Toggle between entering hex, decimal, or binary as your starting value using the mode selector.
  6. 6**Copy results**: Click the copy icon next to any result to copy it to your clipboard for use elsewhere.
  7. 7**Clear and reset**: Use the Clear button to reset all fields and start a new calculation.

Understanding Hexadecimal Numbers

Hexadecimal is a base-16 number system using digits 0-9 and letters A-F (representing 10-15):

Hex DigitDecimal ValueBinary (4 bits)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Why Hexadecimal? Each hex digit represents exactly 4 binary bits. This makes hex a compact way to write binary data. A byte (8 bits) is just 2 hex digits. A 32-bit memory address is only 8 hex characters. Compare writing "11111111" in binary vs "FF" in hex—much easier to read and less error-prone.

Common Prefixes:

  • 0x - Used in programming languages (C, JavaScript, Python): 0xFF
  • # - Used for CSS/HTML color codes: #FF5733
  • h - Sometimes used as suffix: FFh

Hex to Decimal Conversion

Converting hex to decimal manually uses positional notation. Each position is a power of 16:

Formula: Each digit × 16^(position from right, starting at 0)

Example: Convert 2AF to decimal

PositionHex DigitCalculationResult
222 × 16² = 2 × 256512
1A (10)10 × 16¹ = 10 × 16160
0F (15)15 × 16⁰ = 15 × 115
Total512 + 160 + 15687

More Examples:

HexCalculationDecimal
FF(15 × 16) + 15255
100(1 × 256) + 0 + 0256
FFFF(15 × 4096) + (15 × 256) + (15 × 16) + 1565,535
7FFFFFFFMaximum signed 32-bit integer2,147,483,647

This calculator does these conversions instantly—just enter your hex value and see the decimal result.

Decimal to Hex Conversion

Converting decimal to hex involves repeated division by 16:

Method: Divide by 16, note the remainder. Repeat with quotient. Read remainders bottom-up.

Example: Convert 255 to hex

StepDivisionQuotientRemainderHex Digit
1255 ÷ 161515F
215 ÷ 16015F

Result: Read remainders bottom-up = FF

Example: Convert 1000 to hex

StepDivisionQuotientRemainderHex Digit
11000 ÷ 166288
262 ÷ 16314E
33 ÷ 16033

Result: Read bottom-up = 3E8

Quick Reference:

DecimalHex
10A
10064
255FF
256100
10003E8
40961000
65535FFFF

Hex to Binary Conversion

The beauty of hex is that each digit maps directly to 4 binary bits. No complex math needed—just substitute each hex digit with its 4-bit binary equivalent.

Conversion Table:

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

Example: Convert 3F7 to binary

Hex DigitBinary Equivalent
30011
F1111
70111

Result: 0011 1111 0111 = 1111110111 (leading zeros optional)

Example: Convert A5 to binary

  • A = 1010
  • 5 = 0101
  • Result: 10100101

This is why programmers love hex—you can "read" binary data at a glance once you memorize the 16 conversions.

Hexadecimal Arithmetic

Hex arithmetic works just like decimal arithmetic, but you carry/borrow at 16 instead of 10.

Hex Addition:

Adding A + 7:

  • A (10) + 7 = 17 decimal
  • 17 = 16 + 1 = 1 with carry 1
  • Result: 11 hex

Example: 1F + 2A

PositionCalculationResult
UnitsF (15) + A (10) = 259 carry 1
Sixteens1 + 2 + 1 (carry) = 44

Result: 49 hex (= 31 + 42 = 73 decimal)

Hex Subtraction:

Example: 50 - 1A

  • 0 - A: borrow from 5, making it 16 - 10 = 6
  • 4 - 1 = 3
  • Result: 36 hex (= 80 - 26 = 54 decimal)

Hex Multiplication:

Example: A × 5

  • 10 × 5 = 50 decimal
  • 50 = 3 × 16 + 2 = 32 hex

This calculator handles all these operations automatically—just select the operation and enter your values.

Hex Color Codes Explained

Web colors use 6-digit hexadecimal codes representing Red, Green, and Blue (RGB) values:

Format: #RRGGBB

ComponentPositionRangeExample
RedDigits 1-200-FF (0-255)FF = max red
GreenDigits 3-400-FF (0-255)00 = no green
BlueDigits 5-600-FF (0-255)80 = mid blue

Common Color Codes:

ColorHex CodeRGB Values
White#FFFFFF255, 255, 255
Black#0000000, 0, 0
Red#FF0000255, 0, 0
Green#00FF000, 255, 0
Blue#0000FF0, 0, 255
Yellow#FFFF00255, 255, 0
Cyan#00FFFF0, 255, 255
Magenta#FF00FF255, 0, 255
Orange#FF5733255, 87, 51
Purple#8B00FF139, 0, 255

Shorthand Notation: 3-digit codes like #F00 expand to #FF0000 (each digit doubles).

Alpha Channel: 8-digit codes (#RRGGBBAA) include transparency: #FF000080 = 50% transparent red.

Enter any hex color in this calculator to see an instant preview of what it looks like!

Real-World Applications of Hexadecimal

Programming & Software Development:

  • Memory addresses: 0x7FFE0000
  • Debug output and error codes
  • Binary file editors (hex editors)
  • Assembly language programming
  • Bitwise operations and flags

Web Development:

  • CSS colors: color: #3498DB;
  • Unicode characters: \u00A9 (copyright symbol)
  • URL encoding: %20 (space)
  • Base64 and other encodings

Networking:

  • MAC addresses: 00:1A:2B:3C:4D:5E
  • IPv6 addresses: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Packet analysis and network debugging

Electronics & Hardware:

  • Hardware register values
  • I2C/SPI device addresses
  • Microcontroller programming
  • BIOS/UEFI configuration

Cryptography & Security:

  • Hash values (MD5, SHA-256)
  • Encryption keys
  • Digital signatures
  • Certificate fingerprints

Data Storage:

  • File signatures (magic numbers): PDF files start with %PDF (25 50 44 46 hex)
  • Disk sector addresses
  • Database internal IDs

Common Hex Values Every Programmer Should Know

Power of 2 Reference:

DecimalHexSignificance
16102^4
2561002^8 (1 byte max + 1)
10244002^10 (1 KB)
409610002^12 (page size)
65536100002^16
10485761000002^20 (1 MB)

Common Bit Masks:

PurposeHexBinary
Low nibble0F00001111
High nibbleF011110000
Full byteFF11111111
16-bit maxFFFF1111111111111111

ASCII in Hex:

CharacterHexCharacterHex
Space20030
A41a61
Z5Az7A
Newline0ATab09

Special Values:

ValueHexMeaning
Null00Zero/empty
Max signed 32-bit7FFFFFFF2,147,483,647
Max unsigned 32-bitFFFFFFFF4,294,967,295
DeadbeefDEADBEEFDebug marker
CafebabeCAFEBABEJava class file signature

Tips for Working with Hexadecimal

Mental Math Tricks:

  1. Quick hex digit recognition: Memorize A=10, B=11, C=12, D=13, E=14, F=15
  2. Multiply by 16: Shift hex digits left and add a zero (10 hex × 16 = 100 hex)
  3. Divide by 16: Remove the rightmost digit (100 hex ÷ 16 = 10 hex)
  4. Check your work: FF should equal 255, 100 should equal 256

Common Mistakes to Avoid:

  • Confusing O (letter O) with 0 (zero)
  • Forgetting that hex is case-insensitive (FF = ff = Ff)
  • Missing the 0x prefix in code (some languages require it)
  • Treating hex as decimal (10 hex = 16 decimal, not 10!)

Useful Patterns:

  • All same digit: FF, EEE, DDDD—easy to spot in debug output
  • Incrementing: 0, 1, 2, ... 9, A, B, C, D, E, F, 10, 11...
  • Complementing: FF - XX gives you the two's complement base

Programming Best Practices:

  • Use 0x prefix for clarity in code
  • Group hex digits in pairs (bytes) or quads (16-bit words)
  • Comment unusual hex values explaining their meaning
  • Use uppercase for hex in documentation, lowercase in code (style preference)

Pro Tips

  • 💡Memorize the hex-to-decimal equivalents for A-F (10-15)—this speeds up mental conversions significantly.
  • 💡Use the 0x prefix when writing hex in code to avoid confusion with decimal numbers.
  • 💡Each hex digit equals exactly 4 binary bits—use this for quick hex-to-binary conversions.
  • 💡For colors, remember that FF is maximum intensity (255) and 00 is minimum (0) for each RGB channel.
  • 💡When debugging, look for common hex patterns like DEADBEEF, CAFEBABE, or FFFFFFFF—they often indicate specific states.
  • 💡Group hex digits in pairs (bytes) when reading memory dumps or binary files.
  • 💡To multiply a hex number by 16, just append a 0 (like multiplying by 10 in decimal).
  • 💡The two's complement of a hex byte is FF minus the value, plus 1.
  • 💡MAC addresses are 6 bytes written as hex pairs separated by colons: 00:1A:2B:3C:4D:5E.
  • 💡Bookmark common hex references: ASCII table, color palette, and power-of-2 values.
  • 💡Use this calculator's color preview feature to quickly visualize any hex color code before using it in your CSS.
  • 💡When entering large hex numbers, double-check digit count—it's easy to miss or add an extra digit.

Frequently Asked Questions

Hexadecimal is a base-16 number system using digits 0-9 and letters A-F. It's used in computing because each hex digit perfectly represents 4 binary bits, making it a compact way to write binary data. A byte (8 bits) is just 2 hex digits. Programmers use hex for memory addresses, color codes, MAC addresses, and anywhere binary data needs human-readable representation.

Nina Bao
Written byNina BaoContent Writer
Updated January 17, 2026

More Calculators You Might Like