HEX vs RGB: How to Read and Convert Colours
Published 9/17/2025 · 3 min read · Developer tools
Daniel Okonkwo — Front-end developer and tech writer at Allin
Web performance · File formats
Checked against 2 sources
HEX and RGB describe the same colours in different notation. RGB lists red, green and blue as numbers 0–255, like rgb(255, 87, 51). HEX writes the same values in base-16, like #FF5733 — each pair of hex digits is one channel. To convert, split the hex into three pairs and read each as a 0–255 number, or write each RGB value as two hex digits.
HEX and RGB are two notations for the same colours. Here's how to read each, convert between them, and add transparency.
Same colour, two notations
On a screen, every colour is a mix of red, green and blue light. Both HEX and RGB just record how much of each — they describe identical colours, only in different handwriting. RGB is easy to read and adjust by eye; HEX is compact and copy-paste friendly, which is why designers and code both use it. Converting between them changes nothing about the colour itself.
Reading RGB
RGB gives three numbers from 0 to 255, one per channel: rgb(255, 0, 0) is pure red, rgb(0, 255, 0) green, rgb(0, 0, 255) blue. Zero means none of that light, 255 means full. Mixing them makes every other colour — equal amounts of all three give a shade of grey, and all three at 255 give white.
Reading HEX
A HEX colour is a # followed by six digits, two per channel, written in base-16 where the digits run 0–9 then A–F (so F is 15, and FF is 255). #FF5733 breaks down as FF red, 57 green, 33 blue — the very same colour as rgb(255, 87, 51). #FFFFFF is white, #000000 black, and a three-digit shorthand like #F53 expands each digit (so #F53 = #FF5533).
Converting and adding alpha
Converting is just base-swapping each channel: 87 in base-10 is 57 in hex, and back again. To make a colour see-through, add an alpha (opacity) value — rgba(255, 87, 51, 0.5) is 50% transparent, or an eight-digit hex #FF573380 does the same. A converter handles both directions instantly, which saves doing base-16 arithmetic by hand.
Frequently asked questions
- Is HEX or RGB better?
- They give the same result. HEX is compact for code, RGB is easier to read and tweak, and RGBA adds transparency.
- What does #FFFFFF mean?
- All three channels at maximum (255, 255, 255), which is white. #000000 is all channels at zero — black.
- How do I add transparency?
- Use rgba() with a 0–1 alpha value, or an eight-digit hex (#RRGGBBAA) where the last pair sets opacity.
Articles you may find interesting
All guides →Related tools
Sources
Spotted a mistake in this article?