HEX to HSL
Paste a hex code and get HSL: hue in degrees, saturation and lightness in percent.
How HEX to HSL works
Convert to RGB and scale to 0–1. Lightness is the average of the largest and smallest channel. Saturation is their difference divided by 1 − |2L − 1|. Hue is the angle of the largest channel on the color wheel.
#9CAF88 → rgb(156, 175, 136) → max 0.686, min 0.533 → L = 61%, S = 20%, H = 89°. Result: hsl(89, 20%, 61%).
HEX to HSL: worked examples
Eight reference colors, converted by the same formulas as the tool above.
| Color | HEX | HSL | Back to HEX |
|---|---|---|---|
| Red | #FF0000 | hsl(0, 100%, 50%) | #FF0000 |
| Black | #000000 | hsl(0, 0%, 0%) | #000000 |
| White | #FFFFFF | hsl(0, 0%, 100%) | #FFFFFF |
| Gray | #808080 | hsl(0, 0%, 50%) | #808080 |
| Dodger blue | #1E90FF | hsl(210, 100%, 56%) | #1F8FFF |
| Gold | #FFD700 | hsl(51, 100%, 50%) | #FFD900 |
| Sage | #9CAF88 | hsl(89, 20%, 61%) | #9CAF88 |
| Vermilion | #F54927 | hsl(10, 91%, 56%) | #F54B29 |
HSL is written with rounded numbers, so converting back does not always return the original. In this table the biggest difference is 2 steps in one channel, out of 255.
Things that trip people up
- HSL lightness is not perceived lightness.
hsl(60, 100%, 50%)(yellow) has an OKLCH lightness of 0.97;hsl(240, 100%, 50%)(blue) has 0.45. Both are 50% in HSL, yet one is far brighter. Pick contrast with a ratio, not with L. - Grays have no hue. When red, green and blue are equal, saturation is 0 and the hue number is meaningless; tools show 0 by convention.
- Rounding. Hue is a whole number of degrees and S and L are whole percentages, so a round trip can differ by up to about four steps in a channel. Keep the original hex as the source of truth.
Related pages
Frequently asked questions
What is HSL good for?
Making a color lighter, darker or less vivid by changing one number. For even steps between colors, OKLCH works better.
Does converting hex to HSL change the color?
No, but HSL is usually rounded to whole numbers, so converting back can be off by up to about four steps in a channel.
Other converters
Color Picker →
Pick visually, get every code.
Converter →
HEX, RGB, HSL, OKLCH, CMYK.
Contrast Checker →
WCAG 2.2 AA and AAA, with fixes.
Color Blindness →
See colors as others do.
Named Colors →
All 148 CSS color names.
Color Wheel →
Harmonies on three wheels.
Palette Generator →
Lock, shuffle, check contrast.
Color Mixer →
Mix paint or light.
Tailwind Generator →
A 50 to 950 scale from one hex.
Content updated