Why convert RGB to HSL?
RGB describes a color by how much red, green and blue light it contains. That is how screens work, but it is hard to adjust by hand: making a color "a bit lighter" means changing all three numbers. HSL describes the same color as a hue (its position on the color wheel), saturation (how strong it is) and lightness. With HSL, a lighter version is just a higher lightness value, which is why many designers prefer it in CSS.
How to use this converter
- Enter the red, green and blue values from 0 to 255.
- The HSL result and a color swatch update immediately.
- Read the working below to see exactly how the answer was calculated, or copy the
hsl()value for your CSS.
The RGB to HSL formula
First divide each value by 255 so it is between 0 and 1. Then find the largest value (Max), the smallest (Min) and their difference Δ.
L = (Max + Min) / 2
S = Δ / (1 − |2L − 1|) (S = 0 when Δ = 0)
H = 60° × ((G − B)/Δ mod 6) if Max is R
H = 60° × ((B − R)/Δ + 2) if Max is G
H = 60° × ((R − G)/Δ + 4) if Max is B
Worked example
For orange, RGB(255, 128, 0): r = 1, g ≈ 0.502, b = 0. Max = 1 (red), Min = 0, Δ = 1. Lightness = 0.5, so 50%. Saturation = 1 ÷ (1 − 0) = 1, so 100%. Because red is largest, hue = 60 × (0.502 mod 6) ≈ 30°. The result is hsl(30, 100%, 50%).
Frequently asked questions
What does hue 0, 120 and 240 mean?
The hue is an angle: 0° is red, 120° is green and 240° is blue. Values in between are mixes, such as 60° for yellow.
Why is the hue 0 for grey?
Greys have equal red, green and blue, so there is no color direction. Saturation is 0 and the hue does not matter.
How do I convert back?
Use the HSL to RGB converter.