The HSL to hex converter turns hue, saturation, and lightness values into a standard CSS hex color. HSL is intuitive for picking colors — adjust the angle for the hue, then dial vividness and brightness — but most stylesheets, design tokens, and tools want a hex code.
How it works
HSL is converted to RGB first, then RGB is formatted as hex. The RGB step uses the standard algorithm:
- Compute chroma
C = (1 − |2L − 1|) × S, whereLandSare in 0–1. - Find
X = C × (1 − |(H / 60) mod 2 − 1|), picking the right intermediate component for the hue sector. - Choose the
(R′,G′,B′)ordering based on which 60° sector the hue falls in. - Add the lightness match
m = L − C/2to each component, then scale by 255.
Each resulting channel (0–255) is written as a two-digit hex value and joined into #RRGGBB.
Example
Convert hsl(210, 70%, 50%):
- Chroma C = (1 − |2·0.5 − 1|) × 0.70 = 0.70
- Hue 210° is in the 180–240 sector, giving a blue-leaning mix
- The result is approximately
#2680d9, a medium blue
At 0% lightness the result is always #000000, and at 100% it is #ffffff, regardless of hue or saturation. All math runs locally in your browser — nothing is uploaded.