Hex to Decimal
Convert hexadecimal numbers to base-10 decimal, digit by digit.
A designer sends you the colour #FF5733 and asks what that looks like as ordinary RGB numbers. Hexadecimal is exactly this kind of shorthand — compact for anyone working with bytes, opaque to everyone else until you convert it.
Hex is base 16, read the same way you read decimal
A decimal number like 47 means four tens plus seven ones. Hexadecimal works the same way, except each position is worth a power of 16 instead of a power of 10, and a single digit can run from 0 up to 15 — which is why the letters A through F stand in for 10 through 15.
Take the hex value 2F. The 2 sits in the sixteens place and the F sits in the ones place, so the conversion is (2 × 16) + 15 = 47. Longer hex numbers just add more powers of 16 further to the left, the same way thousands and hundreds stack up in decimal.
Every hex digit and its decimal value
| Hex digit | Decimal value |
|---|---|
| 0 – 9 | Same as decimal, 0 through 9 |
| A | 10 |
| B | 11 |
| C | 12 |
| D | 13 |
| E | 14 |
| F | 15 |
Colour codes are three decimal numbers in disguise
A colour code such as #FF5733 packs three bytes into six hex digits — two digits per channel, one channel each for red, green and blue. FF is 255, 57 is (5 × 16) + 7 = 87, and 33 is (3 × 16) + 3 = 51, giving RGB(255, 87, 51), a warm orange-red.
#FFFFFF converts to RGB(255, 255, 255) because every channel is at its maximum, which is why it renders as white. #000000 is black for the same reason in reverse — every channel sitting at zero.
Converting hex to decimal by hand
- Write down each hex digit with its position, counting from the right starting at position 0.
- Convert any letter digits — A through F — to their decimal values, 10 through 15.
- Multiply each digit by 16 raised to its position.
- Add the results together to get the final decimal number.
- Sanity check: any two-digit hex value from 00 to FF should land somewhere between 0 and 255.
Hex to decimal questions
Why does hexadecimal use letters at all?
Because a single hex digit needs sixteen possible values and decimal only has ten digits to offer. A through F were adopted to cover 10 through 15 so that every value still fits in one character.
What is the quickest way to convert a large hex number?
Work from the rightmost digit, multiplying each one by 16 raised to its position and summing the results. For anything longer than two or three digits, using a converter avoids arithmetic mistakes that are easy to make by hand.
Why do web colours use hex instead of plain decimal?
Because two hex digits map exactly onto one byte, the natural unit a colour channel is stored in. Decimal would need three digits per channel and would not align as cleanly with how the value is stored in memory.
Is 0xFF the same as just FF?
Yes. The 0x prefix is a notational convention, mostly from programming languages, that signals ‘the following digits are hexadecimal’. The numeric value is identical whether or not the prefix is present.
Can a hex number be negative?
Hexadecimal itself has no built-in sign. Negative values are usually represented using two’s complement inside a fixed number of bits, which is a separate convention layered on top of the base-16 digits.