Decimal to Hex Converter
Convert base-10 numbers into hexadecimal, the base behind every colour code on the web.
#FF5733 is a colour you can pick in any design tool. It is also three plain decimal numbers — 255, 87, 51 — each one converted to hex and stuck together.
Converting 87 to hex by hand
The standard method is repeated division by 16, keeping the remainders. 87 divided by 16 is 5, remainder 7. 5 divided by 16 is 0, remainder 5. Reading the remainders bottom to top gives 57: 5×16 + 7 = 87.
That is the same method behind any decimal-to-hex conversion, just repeated for bigger numbers. 255 divided by 16 is 15, remainder 15, and 15 in hex is F, so 255 becomes FF — the highest value a single byte can hold.
Breaking #FF5733 down into decimal and hex
| Channel | Decimal | Hex |
|---|---|---|
| Red | 255 | FF |
| Green | 87 | 57 |
| Blue | 51 | 33 |
Why colours are written this way at all
Screen colour is built from red, green and blue light, each channel ranging from 0 to 255 — the full range of a single byte, 8 bits. Write all three channels as decimal and you get something like rgb(255, 87, 51), which works but takes more characters.
Write each channel in hex instead and every value fits in exactly two digits, giving the compact six-character codes — FF5733 — you see everywhere in CSS, design tools and image editors. It is the same numbers, just in the base that pairs most tightly with a byte.
Decimal to hex questions
What method converts decimal to hex by hand?
Repeated division by 16, recording each remainder. Divide the number by 16, note the remainder, then divide the result by 16 again, and keep going until you reach 0 — the remainders read from last to first give the hex value.
Why does a colour channel max out at 255?
Because each channel is stored in a single 8-bit byte, and the largest value 8 bits can hold is 255, or FF in hex. That is why you will never see an RGB value like 300 — it does not fit in a byte.
Why use hex for colours instead of plain decimal?
Hex maps neatly onto bytes — exactly two hex digits per channel, from 00 to FF — and the result is shorter to write than three separate decimal numbers with commas and parentheses. #FF5733 is more compact than rgb(255, 87, 51).
Is FF always the highest value in a hex byte?
Yes. FF is 15×16 + 15, which equals 255, the maximum a single byte can represent. It shows up constantly, not just in colour codes, wherever a full byte is set to its maximum value.
Does converting to hex change the actual colour or value?
No. Hex is only a different way of writing the same number, so 255 and FF, or #FF5733 and rgb(255, 87, 51), represent exactly the same values. Only how they are written changes, not what they mean.