Paste a HEX code to get its hsl() value for CSS. Use the sliders to adjust hue, saturation and lightness.
3 or 6 digits, with or without #
It converts a HEX color code into the hsl() format used in CSS. Paste a code such as #ff922e, ff922e or f92 and the HSL value appears straight away, along with the matching RGB. The sliders let you shift hue, saturation and lightness and read off the new HEX code, which makes it a quick way to build a lighter, darker or more muted version of a brand color.
First convert the HEX pairs to R, G and B, then scale each to 0 to 1 by dividing by 255. With max and min as the largest and smallest of the three and d = max - min:
L = (max + min) / 2
S = 0 if d = 0
S = d / (1 - |2L - 1|) otherwise
H = 60 × (((G - B) / d) mod 6) if R is the max
H = 60 × ((B - R) / d + 2) if G is the max
H = 60 × ((R - G) / d + 4) if B is the max
For #FF922E the channels are 255, 146 and 46, so the scaled values are 1.000, 0.573 and 0.180. That gives d = 0.820, L = 0.590 (59%), S = 1.000 (100%) and H = 60 × 0.478 = 28.7, which rounds to 29. The result is hsl(29, 100%, 59%).
| Color | HEX | HSL |
|---|---|---|
| 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%) |
Hue 0 is red, 60 yellow, 120 green, 180 cyan, 240 blue and 300 magenta. For lighter and darker variations of one color, move only L. To turn a color into a gray, bring S to 0.
Convert the HEX pairs to R, G and B, then divide each by 255. Lightness is the average of the largest and smallest values. Saturation compares their gap to how far lightness sits from the middle. Hue is the angle on the color wheel set by whichever channel is largest. #FF922E becomes hsl(29, 100%, 59%).
H is hue, an angle from 0 to 360 degrees around the color wheel, where 0 is red, 120 is green and 240 is blue. S is saturation, from 0% (gray) to 100% (full color). L is lightness, from 0% (black) through 50% (the pure color) to 100% (white).
HSL is easier to adjust by hand. To make a hover color slightly darker, lower L by 8 or 10 points and leave H and S alone. Doing the same with a HEX code means working out new values for all three channels.
It is rounded to whole numbers, which is how HSL is normally written. Converting back can land one step away in a channel, so the HEX code you get back may differ by 1 in a digit pair. Keep the original HEX when an exact match matters.
Both hsl(29, 100%, 59%) and hsl(29 100% 59%) work in current browsers. The first is the older comma form and the second is the modern form, which also takes alpha as hsl(29 100% 59% / 50%). The tool shows both so you can copy either one.
This page reads 3 and 6 digit codes. If you have an 8-digit code, drop the last two digits to convert the color, then add the opacity yourself in CSS, for example hsl(29 100% 59% / 50%).
Pick a Zaps template for your next post, story or reel, add your photos and match it to your palette.