Convert any HSL or HSLA color to a HEX code. Drag the hue, saturation, lightness and alpha sliders or paste a CSS value like hsl(152, 39%, 30%), and copy the HEX, RGB or modern CSS code.
Accepts hsl(), hsla(), modern hsl(152 39% 30% / 50%) and plain numbers.
Lightness scale (same hue & saturation)
HEX
HEX (no alpha)
RGB
HSL (CSS)
Modern CSS
Advertisement
Advertisement
How to use the HSL to HEX Converter
Set the hue (0–360°), then saturation and lightness (0–100%) with the sliders or number boxes.
Or paste a CSS color such as hsl(152, 39%, 30%), hsla(210, 60%, 45%, 0.5) or hsl(210 60% 45% / 50%).
Adjust alpha if you need transparency; the HEX code switches to 8 digits.
Copy the result: HEX, RGB/RGBA or CSS hsl() code.
Pick a lighter or darker version from the lightness scale to build hover or background colors.
HSL to HEX formula
HSL describes a color by hue (its position on the color wheel, 0–360°), saturation (0% gray to 100% vivid) and lightness (0% black, 50% pure color, 100% white). To get HEX, the color is first converted to RGB with the standard formula from the CSS Color specification, using S and L as fractions from 0 to 1:
Chroma: C = (1 − |2L − 1|) × S
Second component: X = C × (1 − |(H ÷ 60) mod 2 − 1|), and m = L − C ÷ 2
Add m to each component, multiply by 255 and round: that is RGB.
Write R, G and B as two hex digits each: #RRGGBB. An alpha value becomes a fourth pair (alpha × 255).
Example: hsl(152, 39%, 30%) gives C = 0.234, X ≈ 0.125, m = 0.183, so RGB ≈ (47, 106, 78) = #2F6A4E.
Common HSL colors in HEX
Color
HSL
HEX
RGB
Red
hsl(0, 100%, 50%)
#FF0000
255, 0, 0
Orange
hsl(30, 100%, 50%)
#FF8000
255, 128, 0
Yellow
hsl(60, 100%, 50%)
#FFFF00
255, 255, 0
Green
hsl(120, 100%, 50%)
#00FF00
0, 255, 0
Forest green
hsl(152, 39%, 30%)
#2F6A4E
47, 106, 78
Cyan
hsl(180, 100%, 50%)
#00FFFF
0, 255, 255
Sky blue
hsl(200, 80%, 60%)
#47B4EB
71, 180, 235
Blue
hsl(240, 100%, 50%)
#0000FF
0, 0, 255
Purple
hsl(270, 60%, 50%)
#8033CC
128, 51, 204
Magenta
hsl(300, 100%, 50%)
#FF00FF
255, 0, 255
Pink
hsl(330, 80%, 75%)
#F28CBF
242, 140, 191
Gray
hsl(0, 0%, 50%)
#808080
128, 128, 128
Black
hsl(0, 0%, 0%)
#000000
0, 0, 0
White
hsl(0, 0%, 100%)
#FFFFFF
255, 255, 255
Tips for working with HSL
Keep hue and saturation fixed and change only lightness to create a consistent palette of tints and shades. The lightness scale above does exactly that.
Rotating hue by 180° gives the complementary color; 120° steps give a triadic scheme. The Color Wheel shows all harmonies.
Equal HSL lightness does not mean equal perceived brightness: yellow at 50% looks much lighter than blue at 50%. Check text colors with the Color Contrast Checker.
First convert HSL to RGB: C = (1 − |2L − 1|) × S, X = C × (1 − |(H / 60) mod 2 − 1|), m = L − C / 2. Depending on which 60° sector the hue is in, (R', G', B') is a combination of C, X and 0; then R = (R' + m) × 255 and so on. Round each value and write it as two hexadecimal digits to get #RRGGBB.
What is hsl(0, 100%, 50%) in HEX?
It is pure red, #FF0000. In HSL, 50% lightness gives the most vivid version of a hue, 0% is always black and 100% is always white.
How do I convert HSLA to HEX with transparency?
Set the alpha slider or include alpha in the pasted value. The alpha is turned into a fourth pair of hex digits: alpha × 255, rounded. For example hsla(0, 100%, 50%, 0.5) becomes #FF000080.
Why do two HSL values give the same HEX code?
HEX stores whole RGB numbers from 0 to 255, while HSL can be fractional. Small HSL differences can round to the same RGB values, so converting HEX back to HSL may give slightly different numbers than you started with.
Is HSL better than HEX in CSS?
Both describe the same sRGB colors and are supported everywhere. HSL is easier to adjust by hand (change lightness for a hover state, keep the hue), while HEX is shorter and common in design tools and brand guides.
What hue units can I paste?
Plain numbers and deg are degrees. You can also use turn (1turn = 360°), rad and grad, as allowed in CSS.