Hex to HSL Converter
Enter a hex code and read the hue, saturation and lightness beside it. #2E8B57, for example, is hsl(146, 50%, 36%). HSL is the easiest format to adjust by hand, so converting is often the first step in building a color scale.
#2E8B57exactly seagreen
Use 3 or 6 digits, for example #1E90FF or 19F
For example hsl(210, 100%, 56%)
This is the CSS color seagreen #2E8B57
Pick visually and see the other formats
For example rgb(30, 144, 255) or 30 144 255
For example cmyk(88%, 44%, 0%, 0%)
Recent colors
Colors you pick appear here. They stay on this device.
By the Hex Color Picker Team. Updated
How to convert hex to HSL
- Paste the hex code into the hex box, with or without the #.
- Copy the hsl() value from the HSL box.
- To tweak the color, edit the HSL box. Raising lightness lightens it, and the hex code updates as you type.
The math, step by step
There is no direct formula from hex to HSL. The conversion goes through RGB first. #2E8B57 gives rgb(46, 139, 87). Divide each channel by 255, then find the largest and smallest values: green is the largest (139) and red the smallest (46).
Lightness is the average of the two, (139 + 46) / 2 / 255, which is about 36%. Saturation compares the spread between them (93 out of 255) with the room the lightness leaves, and here it works out to 50%. Hue depends on which channel is largest. Green is largest, so the hue sits in the green part of the wheel, at 146 degrees.
Reading the result
- Hue runs 0 to 360 around the color wheel: 0 is red, 120 green, 240 blue.
- Saturation of 0% is a pure grey, and 100% is the most vivid version of the hue.
- Lightness of 0% is black and 100% is white, whatever the hue.
Building a scale from the result
Once you have the HSL value, keep the hue and saturation and change only the lightness to get a family of tints and shades: hsl(146, 50%, 90%) for a pale background, hsl(146, 50%, 36%) for the base color, hsl(146, 50%, 20%) for dark text. That is much harder to do directly in hex.
Quick sanity checks
A few results are worth memorizing. A grey has three matching pairs and always comes out with 0% saturation, so #808080 is hsl(0, 0%, 50%). Pure red #FF0000 is hsl(0, 100%, 50%), and pure blue #0000FF is hsl(240, 100%, 50%). Lightness near 50% with high saturation means a vivid color, while lightness above 90% or below 10% is close to white or black whatever the hue is.
Common questions
Why isn't there a hex to HSL formula that skips RGB?
Hex is just RGB written in base 16, so the conversion always passes through the three channel values.
Will HSL give me back exactly the same hex code?
HSL values here are rounded to whole numbers, so converting back can land one step away in a channel. Keep the hex code as your exact record.