Skip to content
Omnikalc

RGB to HSL converter: hue, saturation and lightness

Enter the red, green and blue values of a color to get its hue, its saturation and lightness in HSL and its saturation and value in HSV.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Results

Hue

204.1 °

Saturation (HSL)
69.9%
Lightness (HSL)
53.1%
Saturation (HSV)
76.3%
Value (HSV)
85.9%

Designers pick colors in hue, saturation and lightness, and browsers and image files use red, green and blue. The RGB to HSL converter takes the red, green and blue values from 0 to 255 and gives the hue, the saturation and the lightness in HSL, and the saturation and value in HSV.

How the calculation works

  • Divide each channel by 255 to get values between 0 and 1. Let max and min be the largest and smallest, and delta = max − min.
  • Lightness (HSL) = (max + min) ÷ 2. Saturation (HSL) = delta ÷ (1 − |2 × lightness − 1|), or 0 for a gray.
  • Hue depends on the largest channel. If it is red, hue = 60 × ((green − blue) ÷ delta). If green, 60 × (2 + (blue − red) ÷ delta). If blue, 60 × (4 + (red − green) ÷ delta). Add 360 if the result is negative.
  • HSV: value = max and saturation = delta ÷ max. HSL is used in CSS as hsl(hue, saturation%, lightness%).

Example

Take rgb(52, 152, 219), the blue #3498DB. The channels are 0.204, 0.596 and 0.859. The largest is blue (0.859) and the smallest is red (0.204), so delta = 0.655. Lightness is (0.859 + 0.204) ÷ 2 = 53.1% and saturation is 0.655 ÷ (1 − 0.063) = 69.9%. The hue is 60 × (4 + (0.204 − 0.596) ÷ 0.655) = 204.1°. In CSS this is hsl(204, 70%, 53%).

Why it matters

HSL makes it simple to build a palette: keep the hue and change the lightness for shades, or turn the hue for related colors. It is used in CSS, design tools and image editing, and converting from a hex code or an RGB value gives you the starting point.

Good to know

The conversion is exact for the sRGB values you enter, but the results are rounded for display. The hue wraps around at 360 degrees, so 359 degrees and 1 degree are close. HSL saturation and lightness are not perceptually uniform: two colors with the same lightness can look very different in brightness, which is why contrast must be checked on the real colors.

The hair color mix calculator blends shades in a different way and the resistor color code calculator is another color-based tool.

Frequently asked questions

What is HSL?

HSL stands for hue, saturation and lightness. The hue is an angle on a color wheel, from 0 for red through 120 for green and 240 for blue. The saturation is how vivid the color is, and the lightness goes from black at 0% to white at 100%. HSL is easier for people to adjust than RGB, since you can make a color lighter without changing its hue.

What is the difference between HSL and HSV?

Both use the same hue. In HSL the lightness runs from black to white with the pure color at 50%. In HSV, also called HSB, the value runs from black to the full color, and white needs low saturation. Design tools often use HSV or HSB for color pickers, and CSS uses HSL.

How do I use HSL in CSS?

Write hsl(204, 70%, 53%) or, in modern CSS, hsl(204 70% 53%). To make a palette, keep the hue and vary the lightness, for example 90% for a background and 30% for a dark text. Changing the hue by 180 degrees gives the complement.

Why do grays have a hue of zero?

When the red, green and blue values are equal, the color is a gray, the delta is zero and there is no dominant channel. The hue is then undefined, and conversion tools show 0 by convention. The saturation of a gray is zero, and only the lightness matters.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.