Blog · Design tools

HSL vs RGB vs hex: which colour format should you use?

Hex, RGB and HSL describe exactly the same colours, so the choice is about readability: hex is best for sharing and copying, rgb() for transparency and code, and HSL for building lighter and darker versions of a colour.

Title card reading “HSL vs RGB vs hex” beside a screenshot of the Digital Sauce hex to RGB converter with #EF466F typed over a large pink swatch and its RGB value beside it.

We get asked this a lot by designers who are starting to write CSS. There is no wrong answer; the browser draws identical colours from all three. Here is how each one thinks, and when we reach for which. To switch between them, use the hex to RGB converter.

One colour, three ways

FormatDigital Sauce pinkThinks in
Hex#EF466FRed, green, blue as base-16 pairs
RGBrgb(239 70 111)Red, green, blue from 0 to 255
HSLhsl(345 84% 61%)Hue (angle on the colour wheel), saturation, lightness

All three are defined in the W3C CSS Color Module Level 4 and describe colours in the sRGB space.

One colour, three descriptions. Hex and RGB store the same three channel numbers; HSL describes the colour as an angle plus two percentages.

When to use hex

  • Sharing a colour in Slack, a brand guide or a ticket: it is short and copy-pastes cleanly.
  • Matching Figma, Sketch and Canva, which all show hex by default.
  • Design tokens and theme files, where one string per colour keeps things tidy.

New to reading hex? See how hex colour codes work.

When to use RGB

  • When you need transparency and want it readable: rgb(239 70 111 / 40%).
  • When code calculates colours, for example blending two colours or reading pixels from a canvas, because the channels are plain numbers.
  • When an SDK wants channel values, often as 0–1 fractions (SwiftUI, shaders), which the converter outputs too.

When to use HSL

HSL is the friendliest format for variations of one colour. Keep the hue and saturation, change the lightness:

--pink-600: hsl(345 84% 51%);  /* pressed */
--pink-500: hsl(345 84% 61%);  /* brand */
--pink-200: hsl(345 84% 88%);  /* tint for backgrounds */

It is also the easiest format for picking harmonious colours, because complementary and triadic schemes are just hue angles 180° or 120° apart. Our colour palette generator uses this to build palettes.

The catch: HSL lightness is not how bright a colour looks. Yellow at 50% lightness looks far brighter than blue at 50%. So two HSL colours with the same lightness can have very different contrast.

What about OKLCH?

CSS Color 4 also defines oklch(), which is designed so that equal lightness values look equally light, fixing HSL's biggest weakness. It is popular for generating accessible colour scales. Check current browser support on MDN before relying on it, and keep hex fallbacks if you support older browsers.

What we do on client projects

We store brand colours as hex in tokens (because that is what everyone shares), generate tints and shades with HSL or OKLCH, and write transparency with rgb(… / alpha). Whatever you pick, be consistent within a file; mixing formats makes reviews harder. For transparency in hex, see hex colour with opacity.

Hex to RGB converterConvert hex colour codes to RGB, RGBA and HSL, and back. Free, no sign-up, runs in your browser.

Open the tool →

FAQ

Is HSL better than RGB?

Not better, just easier for some jobs. HSL is easier for making lighter or darker versions of a colour. RGB is easier when code needs to calculate or blend colours.

Do hex and RGB look different?

No. #EF466F and rgb(239, 70, 111) are the same colour, and the browser renders them identically.

Which colour format is best for CSS?

Any of them. Many teams store colours as hex, use rgb() with a slash for transparency, and use HSL or OKLCH to create tints and shades.

How do I convert HSL to hex?

Paste the hsl() value into the Digital Sauce hex to RGB converter and copy the hex row. HSL values are rounded, so the result can differ by one in a channel.

What is the difference between HSL and HSB?

Both use hue and saturation, but HSL uses lightness, where 100% is always white, while HSB (or HSV) uses brightness, where 100% is the most vivid version of the hue. Design tools often show HSB.

Last updated 16 November 2026. Sources are linked in the text. Spotted something out of date? Email development@digitalsauce.io.

Need a design system that ships?

Digital Sauce designs and builds apps and websites in Melbourne, from brand colours to the code.

Start a project →