Skip to the content

HSL to RGB Converter

Convert a hue, a saturation and a lightness to red, green and blue values from 0 to 255.

The numbers alone will do: 200, 60, 50.

In RGB

rgb(51, 153, 102)

Hue
150°Alpha
100%

In the other notations

Name

seagreennearest CSS name, #2e8b57

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

HSL to RGB by hand

The converter opens with hsl(150, 50%, 40%). This is how that color gets from HSL to RGB, step by step.

  1. Write the two percentages as fractions: S = 0.5 and L = 0.4.
  2. Chroma is how far the strongest channel will be from the weakest: C = (1 − |2 × L − 1|) × S = (1 − |2 × 0.4 − 1|) × 0.5 = 0.4.
  3. Divide the hue by 60° to see which sixth of the color wheel it is in: 150 ÷ 60 = 2.5. A number from 2 to 3 lies between green and cyan.
  4. There green is the strongest channel and gets C, red is the weakest and gets 0, and blue lies in between with X = C × (1 − |2.5 mod 2 − 1|) = 0.4 × 0.5 = 0.2.
  5. Add m = L − C ÷ 2 = 0.4 − 0.2 = 0.2 to all three, so that the lightness comes out right: red 0.2, green 0.6 and blue 0.4.
  6. Multiply by 255 and round: 51, 153 and 102.
  7. Written the CSS way: rgb(51, 153, 102).

Well-known colors in HSL and RGB

ColorHSLRGB
blackhsl(0, 0%, 0%)rgb(0, 0, 0)
whitehsl(0, 0%, 100%)rgb(255, 255, 255)
grayhsl(0, 0%, 50.2%)rgb(128, 128, 128)
redhsl(0, 100%, 50%)rgb(255, 0, 0)
orangehsl(38.8, 100%, 50%)rgb(255, 165, 0)
yellowhsl(60, 100%, 50%)rgb(255, 255, 0)
limehsl(120, 100%, 50%)rgb(0, 255, 0)
greenhsl(120, 100%, 25.1%)rgb(0, 128, 0)
cyanhsl(180, 100%, 50%)rgb(0, 255, 255)
bluehsl(240, 100%, 50%)rgb(0, 0, 255)
purplehsl(300, 100%, 25.1%)rgb(128, 0, 128)
magentahsl(300, 100%, 50%)rgb(255, 0, 255)

Rounding, and the cousin HSV

  • The three results are rounded to whole numbers, because a screen has 256 levels for each channel. Two HSL colors that differ only a little can therefore give the same RGB values: hsl(150.2, 50%, 40%) is rgb(51, 153, 102) as well.
  • With a saturation of 0% the hue drops out. C is 0, and all three channels equal the lightness.
  • HSV, which design programs often call HSB, is converted with the same steps and two other formulas: C = V × S, and the amount added at the end is m = V − C.

The color converter shows a color in all seven notations at once, with a picker to choose it by eye.

See all 8