RGB vs HSL: Pick the Right Color Space

RGB vs HSL: Pick the Right Color Space

Blend equal parts red and blue and the answer is rgb(128, 0, 128) — a dark plum. Most people expect a vivid purple. The gap between those two expectations is the difference between thinking in RGB and thinking in HSL.

Same color, two spellings

RGB / HEX HSL
Stores light per red, green, blue channel hue angle, saturation, lightness
Teal, both ways #0D9488 = rgb(13, 148, 136) hsl(175, 84%, 32%)
Reads as “a lot of green, some blue” “teal, fairly vivid, fairly dark”
Strong at exact values, handoff, matching a spec deriving states from one base color
Weak at “make it 10% lighter” by hand picking an exact screen value

These are not competing standards. HSL is a re-encoding of the same RGB cube: send a value through the color converter and back, and you land where you started, give or take rounding.

Why lightness is not brightness

hsl(60, 100%, 50%) is #FFFF00. hsl(240, 100%, 50%) is #0000FF. Same L, wildly different perceived brightness. HSL’s lightness is the midpoint between the largest and smallest channel, not luminance. A palette built on equal L values will not have equal contrast, which is exactly where accessibility checks start to matter.

Where the midpoint goes wrong

The color blender averages each channel separately:

  • red: round(255 × 0.5 + 0 × 0.5) = 128
  • green: 0
  • blue: round(0 × 0.5 + 255 × 0.5) = 128

That is #800080, or hsl(300, 100%, 25%). Interpolating RGB desaturates the middle: the average of two bright colors is darker than either one. Interpolate the hue instead and you pass through magenta. Neither answer is “correct” — they answer different questions. An even perceptual ramp needs Lab or OKLab, which these tools do not implement.

The split that works

Use HSL for the numbers you edit: hover states, dark-mode ladders, theme variants. Use RGB or hex for the numbers you ship: design tokens, CSS variables, assets. Both describe identical colors, so convert only when you need to compute.

The converter accepts #RGB or #RRGGBB, rgb(r, g, b), and hsl(h, s%, l%) with integer values; alpha is not supported. It runs in your browser and rewrites all three fields as you type. It also rounds hue, saturation, and lightness to whole numbers, so a value that makes a round trip can shift by one unit. Keep that in mind before comparing colors byte for byte.