HSL to Hex Converter

Convert HSL color values to a CSS hex code

Ad placeholder (leaderboard)

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:

  1. Compute chroma C = (1 − |2L − 1|) × S, where L and S are in 0–1.
  2. Find X = C × (1 − |(H / 60) mod 2 − 1|), picking the right intermediate component for the hue sector.
  3. Choose the (R′,G′,B′) ordering based on which 60° sector the hue falls in.
  4. Add the lightness match m = L − C/2 to 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.

Ad placeholder (rectangle)