Hex Calculator
Convert between hexadecimal and decimal numbers. Perform hex arithmetic with step-by-step solutions and preview hex color codes.
Decimal
255
Step-by-Step Conversion
- 1Starting hex value: FF
- 2Position 0: F (15) x 16^0 (1)= 15
- 3Position 1: F (15) x 16^1 (16)= 240
- 4Sum all values: 15 x 1 + 15 x 16= 255
Hexadecimal Arithmetic
Hex to Decimal Reference
Powers of 16
Related Calculators
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**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**View instant conversions**: The calculator automatically shows the decimal and binary equivalents as you type.
- 3**Perform hex arithmetic**: Select an operation (Add, Subtract, Multiply) and enter a second hex value to calculate.
- 4**Preview hex colors**: Enter a 6-digit hex color code (with or without #) to see a live color preview swatch.
- 5**Switch input modes**: Toggle between entering hex, decimal, or binary as your starting value using the mode selector.
- 6**Copy results**: Click the copy icon next to any result to copy it to your clipboard for use elsewhere.
- 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 Digit | Decimal Value | Binary (4 bits) |
|---|---|---|
| 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 |
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
| Position | Hex Digit | Calculation | Result |
|---|---|---|---|
| 2 | 2 | 2 × 16² = 2 × 256 | 512 |
| 1 | A (10) | 10 × 16¹ = 10 × 16 | 160 |
| 0 | F (15) | 15 × 16⁰ = 15 × 1 | 15 |
| Total | 512 + 160 + 15 | 687 |
More Examples:
| Hex | Calculation | Decimal |
|---|---|---|
| FF | (15 × 16) + 15 | 255 |
| 100 | (1 × 256) + 0 + 0 | 256 |
| FFFF | (15 × 4096) + (15 × 256) + (15 × 16) + 15 | 65,535 |
| 7FFFFFFF | Maximum signed 32-bit integer | 2,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
| Step | Division | Quotient | Remainder | Hex Digit |
|---|---|---|---|---|
| 1 | 255 ÷ 16 | 15 | 15 | F |
| 2 | 15 ÷ 16 | 0 | 15 | F |
Result: Read remainders bottom-up = FF
Example: Convert 1000 to hex
| Step | Division | Quotient | Remainder | Hex Digit |
|---|---|---|---|---|
| 1 | 1000 ÷ 16 | 62 | 8 | 8 |
| 2 | 62 ÷ 16 | 3 | 14 | E |
| 3 | 3 ÷ 16 | 0 | 3 | 3 |
Result: Read bottom-up = 3E8
Quick Reference:
| Decimal | Hex |
|---|---|
| 10 | A |
| 100 | 64 |
| 255 | FF |
| 256 | 100 |
| 1000 | 3E8 |
| 4096 | 1000 |
| 65535 | FFFF |
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:
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Example: Convert 3F7 to binary
| Hex Digit | Binary Equivalent |
|---|---|
| 3 | 0011 |
| F | 1111 |
| 7 | 0111 |
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
| Position | Calculation | Result |
|---|---|---|
| Units | F (15) + A (10) = 25 | 9 carry 1 |
| Sixteens | 1 + 2 + 1 (carry) = 4 | 4 |
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
| Component | Position | Range | Example |
|---|---|---|---|
| Red | Digits 1-2 | 00-FF (0-255) | FF = max red |
| Green | Digits 3-4 | 00-FF (0-255) | 00 = no green |
| Blue | Digits 5-6 | 00-FF (0-255) | 80 = mid blue |
Common Color Codes:
| Color | Hex Code | RGB Values |
|---|---|---|
| White | #FFFFFF | 255, 255, 255 |
| Black | #000000 | 0, 0, 0 |
| Red | #FF0000 | 255, 0, 0 |
| Green | #00FF00 | 0, 255, 0 |
| Blue | #0000FF | 0, 0, 255 |
| Yellow | #FFFF00 | 255, 255, 0 |
| Cyan | #00FFFF | 0, 255, 255 |
| Magenta | #FF00FF | 255, 0, 255 |
| Orange | #FF5733 | 255, 87, 51 |
| Purple | #8B00FF | 139, 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:
| Decimal | Hex | Significance |
|---|---|---|
| 16 | 10 | 2^4 |
| 256 | 100 | 2^8 (1 byte max + 1) |
| 1024 | 400 | 2^10 (1 KB) |
| 4096 | 1000 | 2^12 (page size) |
| 65536 | 10000 | 2^16 |
| 1048576 | 100000 | 2^20 (1 MB) |
Common Bit Masks:
| Purpose | Hex | Binary |
|---|---|---|
| Low nibble | 0F | 00001111 |
| High nibble | F0 | 11110000 |
| Full byte | FF | 11111111 |
| 16-bit max | FFFF | 1111111111111111 |
ASCII in Hex:
| Character | Hex | Character | Hex |
|---|---|---|---|
| Space | 20 | 0 | 30 |
| A | 41 | a | 61 |
| Z | 5A | z | 7A |
| Newline | 0A | Tab | 09 |
Special Values:
| Value | Hex | Meaning |
|---|---|---|
| Null | 00 | Zero/empty |
| Max signed 32-bit | 7FFFFFFF | 2,147,483,647 |
| Max unsigned 32-bit | FFFFFFFF | 4,294,967,295 |
| Deadbeef | DEADBEEF | Debug marker |
| Cafebabe | CAFEBABE | Java class file signature |
Tips for Working with Hexadecimal
Mental Math Tricks:
- Quick hex digit recognition: Memorize A=10, B=11, C=12, D=13, E=14, F=15
- Multiply by 16: Shift hex digits left and add a zero (10 hex × 16 = 100 hex)
- Divide by 16: Remove the rightmost digit (100 hex ÷ 16 = 10 hex)
- 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.

