- Home
- Tools
- Color & Design
- Color Converter
- HSL to HEX Converter
HSL to HEX Converter
Enter a hue, a saturation and a lightness and get the six-digit HEX code of that color.
The numbers alone will do: 200, 60, 50.
In HEX
#3399cc
Hue
200°Alpha
100%
In the other notations
Name
steelbluenearest CSS name, #4682b4
HSL to HEX by hand
The converter opens with hsl(200, 60%, 50%). This is how that color gets from HSL to HEX, step by step.
- Write the two percentages as fractions: S = 0.6 and L = 0.5.
- Chroma is how far the strongest channel will be from the weakest: C = (1 − |2 × L − 1|) × S = (1 − |2 × 0.5 − 1|) × 0.6 = 0.6.
- Divide the hue by 60° to see which sixth of the color wheel it is in: 200 ÷ 60 = 3.3333. A number from 3 to 4 lies between cyan and blue.
- There blue is the strongest channel and gets C, red is the weakest and gets 0, and green lies in between with X = C × (1 − |3.3333 mod 2 − 1|) = 0.6 × 0.6667 = 0.4.
- Add m = L − C ÷ 2 = 0.5 − 0.3 = 0.2 to all three, so that the lightness comes out right: red 0.2, green 0.6 and blue 0.8.
- Multiply by 255 and round: 51, 153 and 204.
- Write each of the three as two digits in base 16, the first one counting sixteen times: 51 = 3 × 16 + 3 is
33, 153 = 9 × 16 + 9 is99and 204 = 12 × 16 + 12 iscc. Together:#3399cc.
Well-known colors in HSL and HEX
| Color | HSL | HEX |
|---|---|---|
| black | hsl(0, 0%, 0%) | #000000 |
| white | hsl(0, 0%, 100%) | #ffffff |
| gray | hsl(0, 0%, 50.2%) | #808080 |
| red | hsl(0, 100%, 50%) | #ff0000 |
| orange | hsl(38.8, 100%, 50%) | #ffa500 |
| yellow | hsl(60, 100%, 50%) | #ffff00 |
| lime | hsl(120, 100%, 50%) | #00ff00 |
| green | hsl(120, 100%, 25.1%) | #008000 |
| cyan | hsl(180, 100%, 50%) | #00ffff |
| blue | hsl(240, 100%, 50%) | #0000ff |
| purple | hsl(300, 100%, 25.1%) | #800080 |
| magenta | hsl(300, 100%, 50%) | #ff00ff |
What the three numbers do
- The hue is an angle on the color wheel, so it wraps around: 360° is the same as 0°, and −30° the same as 330°.
- Lightness overrules the other two at its ends. At 0% the result is
#000000and at 100% it is#ffffff, whatever the hue and the saturation say. - A color is at its purest at a lightness of 50%. Above that it is mixed with white, below it with black.
- CSS takes the hue with or without
deg, and the three numbers with commas or with spaces only:hsl(200 60% 50%)is the same color.
The color converter shows a color in all seven notations at once, with a picker to choose it by eye.