HEX to RGB: How Colour Conversion Actually Works
Type #FF6B6B into a stylesheet and a browser paints a warm coral without blinking. But what is that string, really? Six characters, no units, no obvious link to a colour — and yet it carries everything a screen needs to know.
Here's what's hiding inside a hex code, how to turn one into RGB by hand, and why the two formats are really the same number wearing different clothes.
A hex code is just three numbers in disguise
Every colour on a screen is mixed from three lights: red, green and blue. Turn all three off and you get black. Turn them all to full and you get white. Everything else is a recipe — some amount of each.
"Some amount" runs from 0 to 255. That range isn't random. It's the biggest number you can store in eight bits (one byte), and screens have carried eight bits per channel since the early days. So a colour is three numbers, each 0–255: that's RGB, plain and simple. rgb(255, 107, 107) is our coral.
A hex code is that exact same trio, rewritten in base 16. Nothing is added. Nothing is lost. It's a shorter way to spell the same recipe.
Why base 16, of all things?
Base 16 — hexadecimal — counts with sixteen digits instead of ten: 0–9, then A, B, C, D, E, F for ten through fifteen. It looks alien for about a day, then it clicks.
The reason it caught on is tidy: one hex digit holds exactly four bits, so two hex digits hold one byte — one channel — perfectly. No leftovers. A colour needs three bytes, which is six hex digits. That's why hex codes are (almost) always six characters long. The # in front is just a signpost that says "a colour follows".
Converting a hex code to RGB, by hand
Split the six digits into three pairs — red, green, blue:
#FF6B6B→ FF / 6B / 6B
Now turn each pair into a 0–255 number. A two-digit hex pair works like this: the left digit is the "sixteens" and the right digit is the "ones". Multiply the left by 16, add the right.
- FF → F is 15. So (15 × 16) + 15 = 240 + 15 = 255.
- 6B → 6 is 6, B is 11. So (6 × 16) + 11 = 96 + 11 = 107.
Which gives rgb(255, 107, 107). Same coral, no magic. Going the other way — RGB back to hex — you just reverse it: divide each number by 16 for the first digit, and the remainder is the second. Most people do it maybe twice for the practice and then never again, because a tool does it in a keystroke. Paste any value into the Converter and it shows you every format at once, hex and RGB side by side, each one click to copy.
Shorthand, and the fourth number
You'll sometimes see three-digit hex codes like #F66. That's shorthand: each digit is simply doubled, so #F66 means #FF6666. Handy for round numbers, useless for precise ones.
You'll also meet eight-digit hex codes — #FF6B6BCC. The extra pair on the end is alpha: opacity, from 00 (invisible) to FF (solid). It maps to the a in rgba() exactly the way the others map to red, green and blue. So #FF6B6BCC is roughly rgba(255, 107, 107, 0.8).
So which should you actually use?
They render identically, so the choice is about people, not pixels. Hex is compact and copies cleanly from design tools — it's what you'll paste most of the time. RGB earns its keep when you want to read or tweak a colour, because the numbers mean something: bump the middle value and you know green is going up. And rgba() is the honest way to write a semi-transparent colour.
If you're picking colours from scratch rather than converting them, skip the arithmetic entirely and use the Picker — drag to the shade you want and copy it in whichever format your code expects.
Common questions
Is hex better than RGB?
Neither is better; they're the same colour written two ways. Use hex for compact copy-paste, RGB when you want readable numbers or transparency.
What does the # mean?
It marks the string as a hex colour. On its own it means nothing — it's punctuation, like the $ in front of a price.
Why do colours stop at 255?
Because each channel is stored in eight bits, and 255 is the largest value eight bits can hold. It's a hardware limit that became a habit.
Once you see a hex code as three ordinary numbers in a base-16 coat, the mystery evaporates. You don't need to convert by hand — but knowing what's inside means you'll never again treat a colour as an incantation. Grab a value and watch it shape-shift across formats in the Converter.
Ready to try it? Every tool on Paleta runs free in your browser — no sign-up, nothing uploaded.
Explore the tools →