Hex to HSL converter: find hue, saturation and lightness from a hex code
By TechCompare · Updated · How we check
#F59E0B converts to hsl(38, 92%, 50%). All three HSL numbers come from the same red, green and blue channels, so they describe one color in a different form.
- HSL
hsl(38, 92%, 50%) - RGB
rgb(245, 158, 11) - CMYK
cmyk(0%, 36%, 96%, 4%)
HSL describes a color with hue, saturation and lightness instead of red, green and blue. A hex code stores the red, green and blue, so the converter first reads the three pairs, then works out the HSL numbers. For #F59E0B the answer is hsl(38, 92%, 50%). Paste your own code above to see the HSL values with the RGB and CMYK rows beside them.
How this is calculated
Start with the largest and smallest of the three channels. Lightness is the halfway point between them, and saturation measures how far apart they are, scaled to the room left at that lightness. A gray with no spread has no saturation. For #F59E0B, lightness is 50% and saturation is 92%.
Hue is a spot on the color wheel: 0 is red, 120 is green and 240 is blue. The largest channel picks the section of the wheel, and the gap between the other two moves the hue toward the next color. For #F59E0B, red is the largest channel and green comes next, so the hue sits between red and yellow at 38 degrees. The CSS Color 4 spec gives the sample code for these steps.
A gray has all three channels equal, so there's no spread and no real hue. The gray #808080 converts to hsl(0, 0%, 50%), with hue 0 and saturation 0%. Writing hsl(38, 92%, 50%) back as hex gives #F59F0A, not #F59E0B. The HSL numbers are rounded to whole numbers, so keep the hex as the source of truth. The HSL to Hex page covers the other direction.
Verdict
Keep the hex code as the record of the color, and reach for HSL when you want to adjust it by hand. Changing one HSL number can make a color lighter, darker or more muted. Hex doesn't give you that kind of single control. The HSL color model page shows how that works in CSS.
More Color scenarios
Related guides
Frequently asked questions
Is HSL the same as HSV?
What hue does a gray get?
Why do two hex codes give the same HSL?
How do I work out the hue by hand?
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