How to convert HSL to HEX
- Chroma = (1 − |2 × L − 1|) × S, with S and L as fractions from 0 to 1.
- Divide the hue by 60 to find which sixth of the color wheel it is in, and work out a second value X = chroma × (1 − |(H ÷ 60) mod 2 − 1|).
- Assign chroma, X and 0 to red, green and blue depending on that sixth, then add L − chroma ÷ 2 to each.
- Multiply by 255, round, and write each value as two hex digits: hsl(24, 100%, 50%) is #ff6600.
From a design idea to a code
Many palettes start in HSL: a designer picks a hue and then lighter and darker steps. Websites, apps and brand guides, however, usually store the final colors as HEX codes. Converting turns each step into a code you can hand to developers or paste into a theme.
Because HEX has only 256 levels per channel, very small HSL changes can produce the same HEX code. If you nudge lightness by 0.1% and the HEX code does not change, the two colors are identical on screen.
Entering HSL values
Hue is an angle from 0 to 360 degrees; 360 is the same as 0 (red). Saturation and lightness are percentages from 0 to 100. You can write them with commas, hsl(24, 100%, 50%), or with spaces, hsl(24 100% 50%). Add a fourth value, or / 50%, for transparency.
At 0% lightness every hue is black, and at 100% every hue is white, so the hue and saturation do not matter there. At 0% saturation every color is a grey.
Checking HSL colors by eye
Because HSL numbers are easy to adjust, it is tempting to change them without looking. The preview and the contrast checker on this page show the result straight away. Colors with the same lightness value can look very different in brightness: yellow at 50% lightness appears much brighter than blue at 50%, which matters for readable text.
Use the contrast checker to confirm that a color generated from HSL still meets accessibility guidelines before you copy its HEX code.
HSL to HEX chart of common colors
HSL to HEX values for common colors| Color | HSL | HEX |
|---|
| Black | hsl(0, 0%, 0%) | #000000 |
| White | hsl(0, 0%, 100%) | #ffffff |
| Red | hsl(0, 100%, 50%) | #ff0000 |
| Lime | hsl(120, 100%, 50%) | #00ff00 |
| Blue | hsl(240, 100%, 50%) | #0000ff |
| Yellow | hsl(60, 100%, 50%) | #ffff00 |
| Cyan | hsl(180, 100%, 50%) | #00ffff |
| Magenta | hsl(300, 100%, 50%) | #ff00ff |
| Silver | hsl(0, 0%, 75.3%) | #c0c0c0 |
| Gray | hsl(0, 0%, 50.2%) | #808080 |
| Maroon | hsl(0, 100%, 25.1%) | #800000 |
| Olive | hsl(60, 100%, 25.1%) | #808000 |
| Green | hsl(120, 100%, 25.1%) | #008000 |
| Purple | hsl(300, 100%, 25.1%) | #800080 |
| Teal | hsl(180, 100%, 25.1%) | #008080 |
| Navy | hsl(240, 100%, 25.1%) | #000080 |
| Orange | hsl(38.8, 100%, 50%) | #ffa500 |
| Tomato | hsl(9.1, 100%, 63.9%) | #ff6347 |
Other colors: use the converter above or the Color Converter.