Home › Converters › HSL to Hex
HSL to Hex
Design tools and CSS speak two color languages: your mockup may describe a color as hsl(210, 50%, 40%) while a stylesheet, brand guide or teammate wants the hex code. This HSL to hex converter bridges the two — drag the hue, saturation and lightness sliders or type the values, watch the live swatch, and copy the hex or RGB code with one click. It also runs in reverse: paste a hex code into the box at the bottom and the sliders set themselves to the matching HSL values.
How it works
HSL describes a color the way people naturally think about it. Hue is the position on the color wheel: 0 is red, 120 is green, 240 is blue, and the wheel wraps around so 360 lands back on red. Saturation is how vivid the color is — 0% is a shade of gray, 100% is the full-strength color. Lightness is how bright it is — 0% is always black, 100% is always white, and 50% is the color at full strength.
Hex, by contrast, stores the red, green and blue channel values in base 16. So converting HSL to hex is a two-step job: first turn HSL into RGB, then write each RGB channel as a two-digit hex pair. The RGB step uses the chroma — the distance between the lightest and darkest channel — and works out where the hue falls in its 60-degree slice of the wheel:
Once the three channels exist as numbers from 0 to 255, each one converts by dividing by 16: the quotient is the first hex digit, the remainder is the second, with 10–15 written as A–F and single digits padded with a leading zero. The pairs join in red-green-blue order behind a # sign. This page runs exactly that math and shows its work in the result line, and it also prints the matching CSS hsl() notation so you can copy whichever format your project uses.
Worked example
A designer in Austin is moving a steel-blue button color from a design file into CSS. The file lists the color as hsl(210, 50%, 40%).
Step 1: Chroma — (1 − |2 × 0.40 − 1|) × 0.50 = (1 − 0.20) × 0.50 = 0.40.
Step 2: Hue 210 sits in the 180–240 slice, so the channels are (0, X, C) with X = 0.40 × (1 − |3.5 mod 2 − 1|) = 0.40 × 0.50 = 0.20, and m = 0.40 − 0.20 = 0.20.
Step 3: RGB = (0.20, 0.40, 0.60) × 255 = (51, 102, 153).
Step 4: Hex pairs — 51 becomes 33, 102 becomes 66, 153 becomes 99.
The converter gives #336699 for hue 210, saturation 50% and lightness 40% — the same result, instantly, with the RGB triple rgb(51, 102, 153) shown underneath.
Common mistakes and tips
The classic mix-up is treating HSL lightness like a brightness dial for the hex code itself — there is no shortcut: a 10-point lightness change moves all three RGB channels by different amounts depending on the hue, which is exactly why a converter beats mental math. Another trap is the second color model with a similar name: HSV (also called HSB) shares the hue wheel but its S and V numbers mean different things, so hsl(210, 50%, 40%) and hsv(210, 50%, 40%) are visibly different colors.
Two practical tips. First, hue wraps: 360 and 0 are the same red, and this converter accepts both. Second, when saturation is 0% the hue stops mattering — every hue gives the same gray, set purely by lightness. That is a handy way to build a gray scale: keep saturation at 0 and step lightness by 10.
FAQ
What is hsl(210, 50%, 40%) in hex?
hsl(210, 50%, 40%) is #336699 in hex. The HSL values first convert to rgb(51, 102, 153), and each channel then becomes a two-digit hex pair: 51 is 33, 102 is 66 and 153 is 99.
How do I convert HSL to hex by hand?
First convert HSL to RGB: work out the chroma C = (1 − |2L − 1|) × S, find the second component X from the hue's 60-degree slice, add m = L − C ÷ 2 to each channel and multiply by 255. Then write each RGB channel as a two-digit hex pair and join the three pairs behind a # sign.
Is hue 360 the same color as hue 0?
Yes. Hue is an angle on a color wheel, so 360 degrees lands exactly where 0 degrees starts: pure red. This converter accepts both 0 and 360 and treats them as the same hue.
What is the difference between HSL and HSV?
They share the same hue wheel, but the other two numbers differ. In HSL, 100% lightness is always white and 50% is the full-strength color. In HSV (or HSB), 100% value is the full-strength color and there is no white point. The same three numbers give different colors in the two models, so check which one your tool uses.
Can I convert a hex code back to HSL here?
Yes. Type or paste a hex code into the hex box at the bottom of the converter — 6 digits like #336699 or the 3-digit short form like #369 — and the hue, saturation and lightness sliders and number boxes all update to match.