HSL to hex converter: turn hue, saturation and lightness into a hex code

By TechCompare · Updated · How we check

hsl(190, 75%, 60%) converts to #4CCCE6, which is the code to paste into a stylesheet or design tool.

  • HEX#4CCCE6
  • RGBrgb(76, 204, 230)
  • CMYKcmyk(67%, 11%, 0%, 10%)

HSL writes a color as hue, saturation and lightness. A stylesheet or design tool that asks for hex needs the six-digit code, so this converter turns those three numbers into it. Type a value like hsl(190, 75%, 60%) into the converter and you get #4CCCE6, with RGB and CMYK beside it.

Conversion
HSL to HEX
Example: hsl(190, 75%, 60%)
Category
Web Formats
Color knowledge base

How this is calculated

Hue picks the spot on the color wheel: 0 is red, 120 is green and 240 is blue, with the other hues in between. Saturation sets how far the color sits from gray, and lightness sets how far it sits from black or white. At full saturation, 50% lightness gives the pure hue. Those three numbers produce red, green and blue values from 0 to 1. The converter scales them to 0 to 255, rounds each to a whole number and writes the pairs. CSS Color 4 gives the sample code for these steps.

The page's own color runs through every step: hsl(190, 75%, 60%) gives rgb(76, 204, 230), which is #4CCCE6. Pure red makes a good check, since hsl(0, 100%, 50%) gives #FF0000. At 0% saturation the hue stops mattering. Any hue gives a gray at the chosen lightness. For example, hsl(0, 0%, 50%) gives #808080.

Hex has 16.7 million codes. Whole-number HSL has far fewer combinations, so some hex codes can't be reached exactly. This page's color survives the trip: #4CCCE6 to HSL and back gives #4CCCE6. Take #3B82F6, write it as HSL and convert back, and the result is #3C83F6. Keep the hex when you need an exact match.

Verdict

Save the hex code as the final value, and use HSL when you want to move a color in a known direction, like making it lighter. When a color has to match an exact hex, keep that hex as the source and check the converted result against it before you ship it.

More Color scenarios

Hex to RGB
A hex color code is three RGB numbers written in base 16.
View details
RGB vs CMYK
Screens add light and print adds ink. See one color in both, and why a plain CMYK formula can't promise a print match.
View details
HSL color model
Hue, saturation and lightness, with three live sliders and a table of common colors in hex, RGB and HSL.
View details

Frequently asked questions

What are the HSL ranges?
Hue runs from 0 to 360 degrees, and saturation and lightness each run from 0% to 100%. The converter shows an error for any value outside those limits, such as a hue above 360 or a saturation above 100%. It also reads decimals, so a hue of 38.5 converts.
Can I type HSL with percent signs or without?
Both work. The converter takes saturation and lightness with or without the % sign, and hue with or without deg. It reads the hsl() wrapper too, with commas or spaces between the parts.
Does hue 360 equal hue 0?
Yes. The color wheel wraps, so hue 360 and hue 0 are both red, and the converter gives #FF0000 for either one.
Why does my converted hex look slightly off?
The HSL you started with may already be rounded. Whole-number HSL can't hold every hex code, so the converted hex can land a little off the original. Get the hex from the source when you can. If your source gives decimals, type them, since the converter reads them.