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 - RGB
rgb(76, 204, 230) - CMYK
cmyk(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.
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
Related guides
Frequently asked questions
What are the HSL ranges?
Can I type HSL with percent signs or without?
Does hue 360 equal hue 0?
Why does my converted hex look slightly off?
Related tools
Contrast Checker
Check color contrast ratios for WCAG AA/AAA accessibility compliance.
Use toolJSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolAspect Ratio Visualizer
Visually compare width differences between 16:9, 21:9, and 32:9 monitors.
Use tool