Hex to Decimal Conversion Explained
Understand hexadecimal numbers and how to convert between hex, decimal, binary, and octal. Includes color code conversion.
Hexadecimal (hex) is a base-16 number system that programmers encounter daily — in color codes, memory addresses, character encodings, and network protocols. Despite its ubiquity, many developers rely on converters without fully understanding the underlying math. This guide demystifies number systems and gives you a solid grasp of how hex, decimal, binary, and octal relate to each other.
Number Systems Explained
A number system (or base) defines how many unique digits are available before you need a second position. We use decimal (base-10) daily because we have 10 digits: 0 through 9. After 9, we carry over to the next position: 10, 11, 12, and so on.
The same principle applies to every other base:
- Binary (base-2):Uses only 0 and 1. Each digit is a “bit.” This is the native language of computers since electronic circuits have two states: on and off. The decimal number 10 is 1010 in binary.
- Octal (base-8): Uses digits 0-7. Historically used in Unix file permissions (like 755 or 644). The decimal number 10 is 12 in octal.
- Decimal (base-10): Our everyday system with digits 0-9. It likely evolved because humans have 10 fingers.
- Hexadecimal (base-16): Uses digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). The decimal number 10 is A in hex. The decimal number 255 is FF.
Why Hexadecimal Is Used in Computing
The key insight is that hex maps perfectly to binary. Each hex digit represents exactly 4 binary bits:
Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F Dec: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bin: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
This means one byte (8 bits) can always be written as exactly 2 hex digits. The binary value 11111111 is FF in hex and 255 in decimal. Reading FF is much faster than reading 11111111, and it maintains the direct relationship to the binary that decimal obscures.
This is why hex appears everywhere in programming:
- Memory addresses: 0x7FFF5FBFF8A0 is a typical 64-bit pointer — far more readable than its decimal equivalent 140,734,799,804,576.
- Color codes: #FF5733 represents a specific RGB color, with each pair being one byte.
- Character encoding: Unicode code points are written in hex (U+1F600 for the grinning face emoji).
- Bitwise operations: Bitmasks like 0xFF00 are instantly readable as “the upper byte of a 16-bit value.”
Color Codes and Hex
CSS hex color codes are the most visible use of hexadecimal for most web developers. A color like #2DD4BF is actually three hex bytes concatenated:
- 2D = Red channel = 45 in decimal (out of 255)
- D4 = Green channel = 212 in decimal
- BF = Blue channel = 191 in decimal
So #2DD4BF is equivalent to rgb(45, 212, 191). The shorthand #F53 expands to #FF5533 by doubling each character.
An optional fourth byte adds alpha (transparency): #2DD4BF80 is the same teal at 50% opacity (80 hex = 128 decimal, which is roughly 50% of 255). If you need to extract colors from an image, the resulting HEX codes follow this same format.
Common Conversions Reference Table
| Decimal | Hex | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0000 | 0 |
| 10 | A | 1010 | 12 |
| 15 | F | 1111 | 17 |
| 16 | 10 | 10000 | 20 |
| 100 | 64 | 1100100 | 144 |
| 127 | 7F | 1111111 | 177 |
| 128 | 80 | 10000000 | 200 |
| 255 | FF | 11111111 | 377 |
| 256 | 100 | 100000000 | 400 |
| 1024 | 400 | 10000000000 | 2000 |
| 65535 | FFFF | 1111111111111111 | 177777 |
Notice the patterns: powers of 2 (128, 256, 1024) have clean hex representations (80, 100, 400). The maximum value of a byte (255) is FF, and the maximum of two bytes (65,535) is FFFF.
Convert hex to decimal instantly
Use our Hex to Decimal tool for instant conversions between hex, decimal, binary, and octal. Includes color code breakdown. Runs entirely in your browser.
Open Hex to DecimalFrequently Asked Questions
Why do programmers use hexadecimal?
Hex provides a compact, human-readable representation of binary data. Each hex digit maps exactly to 4 bits, so a byte is always exactly 2 hex digits. This makes it far easier to read and mentally parse than long binary strings, while maintaining a direct mathematical relationship that decimal doesn't have.
What is 0xFF in decimal?
0xFF equals 255 in decimal. The 0x prefix indicates hexadecimal in most programming languages. F is 15 in decimal, so FF = (15 × 16) + 15 = 255. This is the maximum value of a single byte (all 8 bits set to 1), making it one of the most common hex values you'll encounter.
How does hex relate to CSS colors?
CSS hex colors like #FF5733 are three hex byte values for Red (FF = 255), Green (57 = 87), and Blue (33 = 51). Each pair ranges from 00 (none) to FF (full intensity). An optional fourth pair controls alpha transparency. The shorthand #F53 doubles each character to #FF5533. You can use our JSON viewer to inspect color configurations in design tokens and theme files.