HEX vs RGB vs HSL: Choosing the Right Colour Format
The differences between HEX, RGB and HSL, when each is most useful, and how to convert between them without guessing.
Design work constantly moves between colour notations: HEX in CSS, RGB in design tools, HSL when you need to reason about lightness and saturation. Converting by hand invites mistakes.
Enter a colour in any notation and the other formats update immediately. A range of shades is generated as well, which is handy for building hover and border colours.
Runs locally in your browser — nothing is uploaded.
They describe the same colour in different bases. HEX is base-16, so #ff0000 is red; RGB states the three channel values as decimal numbers, 255, 0, 0.
HSL stands for hue, saturation and lightness. Hue is the colour angle from 0 to 360, saturation controls how grey the colour is, and lightness moves it from black to white.
The extra digits encode opacity. Six digits are opaque; eight digits include an alpha channel, for example #ff000080 for half-transparent red.
HEX is compact for CSS, RGB matches how screens emit light, and HSL matches how people describe colour: hue, saturation, lightness. The same colour looks different in each notation, which is why designers switch between them for different tasks.
Contrast is a separate question from format. WCAG asks for a 4.5:1 ratio for normal text and 3:1 for large text; a colour that looks pleasant in isolation can fail when it sits on a white card.