Convert HSL colors to hex codes, with RGB and CMYK values alongside.
Enter a valid HSL value, like hsl(160, 84%, 39%)
Hue picks a point on the color wheel, saturation sets how vivid it is, and lightness moves it toward black or white. The converter turns those into red, green and blue:
C = (1 − |2L − 1|) × S
X = C × (1 − |(H ÷ 60) mod 2 − 1|)
m = L − C ÷ 2
(R, G, B) = the hue's sector of (C, X, 0), plus mEach channel is then multiplied by 255 and written as two base-16 digits. For hsl(160, 84%, 39%) that gives #10B77F, very close to Tailwind's emerald-500 (#10B981), which rounds to the same HSL value.
| Color | HSL | Hex |
|---|---|---|
| White | hsl(0, 0%, 100%) | #FFFFFF |
| Black | hsl(0, 0%, 0%) | #000000 |
| Red | hsl(0, 100%, 50%) | #FF0000 |
| Orange | hsl(39, 100%, 50%) | #FFA500 |
| Yellow | hsl(60, 100%, 50%) | #FFFF00 |
| Green | hsl(120, 100%, 25%) | #008000 |
| Blue | hsl(240, 100%, 50%) | #0000FF |
| Purple | hsl(300, 100%, 25%) | #800080 |
| Pink | hsl(350, 100%, 88%) | #FFC0CB |
| Gray | hsl(0, 0%, 50%) | #808080 |
Type the HSL value above in any format, like hsl(160, 84%, 39%), hsl(160 84% 39%) or just 160 84 39. The hex code updates as you type. By hand, turn HSL into red, green and blue, multiply each by 255 and write it in base 16.
HSL stands for hue, saturation and lightness. Hue is the angle on the color wheel from 0 to 360, where 0 is red, 120 is green and 240 is blue. Saturation and lightness are percentages.
Neither is better. They're different ways to write the same colors. HSL is easier to tweak by hand, while hex is shorter and is what most design tools, brand guides and color pickers use.
HSL values are usually rounded to whole numbers. A hex code has more precision than a rounded HSL value, so converting hex to HSL and back can shift a channel by one or two.