Convert hex codes to HSL for CSS and design systems, with RGB and CMYK values alongside.
Enter a valid Hex value, like #3B82F6
A hex code is red, green and blue written in base 16. To get HSL, each channel is divided by 255, and the largest (max) and smallest (min) values decide the rest:
L = (max + min) ÷ 2
S = (max − min) ÷ (1 − |2L − 1|)
H = which channel is max, and how far the
other two are from each other, in degreesFor #3B82F6, Tailwind's blue-500, that gives hsl(217, 91%, 60%). Values here are rounded to whole numbers, which is how most design tools show them.
| Color | Hex | HSL |
|---|---|---|
| White | #FFFFFF | hsl(0, 0%, 100%) |
| Black | #000000 | hsl(0, 0%, 0%) |
| Red | #FF0000 | hsl(0, 100%, 50%) |
| Orange | #FFA500 | hsl(39, 100%, 50%) |
| Yellow | #FFFF00 | hsl(60, 100%, 50%) |
| Green | #008000 | hsl(120, 100%, 25%) |
| Blue | #0000FF | hsl(240, 100%, 50%) |
| Purple | #800080 | hsl(300, 100%, 25%) |
| Pink | #FFC0CB | hsl(350, 100%, 88%) |
| Gray | #808080 | hsl(0, 0%, 50%) |
Paste the hex code above and the HSL value appears instantly. By hand, turn the hex into RGB, then find hue from which channel is largest, lightness from the average of the largest and smallest channel, and saturation from how far apart they are.
They describe the same colors in different ways. Hex writes red, green and blue as base-16 numbers. HSL describes a color by its hue, how saturated it is and how light it is. Every hex code has an HSL equivalent, and browsers accept both.
HSL is easier to adjust by hand. To make a lighter or darker shade, change only the lightness. To make a muted version, lower the saturation. That makes HSL handy for hover states, color scales and theme variables.
Both work in every modern browser. The comma version is older and more familiar. The space-separated version is the newer CSS syntax and lets you add opacity with a slash, like hsl(217 91% 60% / 50%).