RGB to HSL Conversion

RGB to HSL Converter

Enter red color (R):
Enter green color (G):
Enter blue color (B):
   
Hue (H): °  
Saturation (S): %  
Lightness (L): %  
Color preview:  

RGB to HSL Conversion

It is a color conversion calculator used to convert red, green and blue colors (RGB) to hue, saturation, and lightness (HSL). Hue is expressed in degrees while saturation and lightness are often expressed as percentages. The hex code is designated by both letters and numbers and the RGB values range from 0 to 255. To use the calculator, enter the RGB hex code in the initial blank text field and then click the ‘Convert' button.

You can also enter the red, green and blue colors in their blank text fields respectively. The conversion result of hue, saturation, and lightness will be displayed below the two controls. The color preview of the HSV result is indicated at the bottom platform of the calculator. The ‘Reset' button is used when you want to perform new conversions from RGB to HSV

Example

Convert 39 red, 26 green and 56 blue color codes into HSL.

Solution

First, enter the RGB values (39, 26 and 56) in their respective text fields. Initiate the conversion by clicking the ‘Convert' button. The conversion result will be displayed as;

Hue (H): 266 degrees

Saturation (S): 36.6%

Lightness (L): 16.1%

The color preview of the above HSL values can be visualized at the bottom panel of the converter.

Formula for converting RGB to HSL

To change the range from 0 to 255 into 0 to 1, the red, green and blue values are divided by 255.

 R' = R/255 G' = G/255 B' = B/255

Cmax = max(R', G', B')

Cmin = min(R', G', B')

Δ = Cmax – Cmin

Hue Calculation

0˚   Δ = 0

60 ˚ x (G'-B'Δmod6), Cmax = R'

60 ˚ x (B'-R'Δ+2), Cmax = G'

60 ˚ x (R'-G'Δ+4), Cmax = B'

Saturation calculation

0, Δ = 0

Δ / 1 - /2L – 1/, Δ <> 0 

Lightness calculation

L = (Cmax + Cmin) / 2