What Is HSL?
HSL stands for Hue, Saturation and Lightness. It describes colours the way people naturally think about them, rather than as amounts of red, green and blue light:
- Hue is the position on the colour wheel, from 0° to 360°: 0° is red, 60° yellow, 120° green, 180° cyan, 240° blue and 300° magenta.
- Saturation is the colour's intensity, from 0% (grey) to 100% (fully vivid).
- Lightness runs from 0% (black) through 50% (the pure colour) to 100% (white).
RGB is how screens actually produce colour, but it's hard to adjust by eye: to make rgb(52, 152, 219) a bit darker, which numbers should you change? In HSL the answer is obvious: lower the lightness. That's why designers and front-end developers use HSL to build colour themes, hover states, tints and shades, and accessible palettes. CSS supports it directly with hsl().
How to Use the RGB to HSL Converter
- Enter a colour in any format (RGB, HEX, HSL or a colour name), or use the picker.
- Or drag the sliders. Moving the RGB sliders updates HSL instantly, and vice versa. The slider tracks show the colours you'd get along each one.
- Copy the result in classic CSS (
hsl(204, 70%, 53%)), modern space-separated syntax, or high precision. - Read the formula steps to see exactly how your colour was converted, which is ideal for learning or checking homework.
The RGB to HSL Formula
- Divide R, G and B by 255 to get values between 0 and 1: R′, G′, B′.
- Find Max and Min of the three, and Δ = Max − Min.
- Lightness: L = (Max + Min) / 2.
- Saturation: if Δ = 0, S = 0; otherwise S = Δ / (1 − |2L − 1|).
- Hue: if Max is R′, H = 60° × ((G′ − B′)/Δ mod 6); if Max is G′, H = 60° × ((B′ − R′)/Δ + 2); if Max is B′, H = 60° × ((R′ − G′)/Δ + 4).
Example: rgb(52, 152, 219) → R′ = 0.204, G′ = 0.596, B′ = 0.859. Max = 0.859 (blue), Min = 0.204, Δ = 0.655. L = 0.531 (53%), S = 0.655 / 0.937 = 0.70 (70%), H = 60 × ((0.204 − 0.596)/0.655 + 4) ≈ 204°. So the colour is hsl(204, 70%, 53%).
HSL to RGB
To go back, compute the chroma C = (1 − |2L − 1|) × S, an intermediate X = C × (1 − |(H/60°) mod 2 − 1|), and m = L − C/2. Depending on which 60° sector the hue falls in, (R′, G′, B′) is a permutation of (C, X, 0). Add m to each and multiply by 255. The converter does this automatically when you move the HSL sliders.
HSL vs RGB vs HSV
| Model | Components | Best for |
|---|---|---|
| RGB | Red, green, blue (0–255) | How screens display colour; image data |
| HSL | Hue, saturation, lightness | CSS theming, tints and shades, readable adjustments |
| HSV / HSB | Hue, saturation, value | Colour pickers in Photoshop, Figma and other design apps |
| HWB | Hue, whiteness, blackness | Intuitive mixing with white and black; CSS Color 4 |
HSL and HSV share the same hue but define saturation differently. In HSL, 100% lightness is always white. In HSV, 100% value is the brightest version of the colour. Photoshop's colour picker uses HSB (the same as HSV), so its numbers won't match HSL. This tool shows both.
Practical Tips for Using HSL in CSS
- Hover and active states: keep hue and saturation, and change lightness by 5–10%.
- Dark mode: keep the hue and adjust lightness and saturation for dark backgrounds.
- Consistent palettes: vary the hue at a fixed saturation and lightness to get evenly matched colours.
- CSS variables: store the hue once (
--brand-h: 204) and build every shade withhsl(var(--brand-h) 70% 40%).
Frequently Asked Questions
What is pure red in HSL?
hsl(0, 100%, 50%), which equals rgb(255, 0, 0).
Why is the hue 0 for grey colours?
Greys have no saturation, so hue is undefined. By convention it's reported as 0.
Why do my converted values differ by 1?
HSL values are usually rounded to whole numbers, so converting back can shift an RGB channel by 1. Use the precise values for exact round-trips.
Is HSL the same as HSB?
No. They share the hue, but HSB/HSV measures brightness differently from HSL's lightness.
Do all browsers support hsl()?
Yes. hsl() and hsla() work everywhere, and the space-separated CSS Color 4 syntax works in all modern browsers.