RGB to HSL

Convert RGB colors to HSL as you type, with a live preview, the formula and a table of common colors converted.

loading RGB to HSL
About this tool

What are RGB and HSL?

RGB gives the same three sRGB channels as decimal numbers from 0 to 255, plus an optional alpha. HSL describes the same sRGB color as hue (0–360°), saturation and lightness (0–100%), which makes lighter and darker shades easy to write by hand.

Converting a sampled RGB color to HSL tells you at once if it is saturated or grayish and how light it is, which helps building a palette around it.

The color converter below starts from RGB and highlights HSL, next to HWB, LAB, LCH and CSS names.

RGB vs HSL

RGBHSL
Notationrgb(255 178 36), rgb(255, 178, 36)hsl(39 100% 57%)
In CSSall browsersall browsers
Typical usecode that computes colors, canvas, image librariesthemes and shades in CSS

Formula

With channels scaled to 0–1: lightness L = (max + min) / 2; saturation S = (max − min) / (1 − |2L − 1|); hue H is the angle of the largest channel (red 0°, green 120°, blue 240°) shifted by the difference of the other two. The reverse builds the channels back from the same three numbers.

What changes in the conversion

  • RGB and HSL describe the same sRGB color; the only difference is rounding of the last digit.
  • Transparency (alpha) is kept: #RRGGBBAA, rgb(… / 0.5), hsl(… / 50%) and oklch(… / 0.5) all carry it.

How to convert RGB to HSL

  1. Type or paste the RGB value in its line, or pick a color with the color picker.
  2. Read the HSL line, which updates as you type, and check the preview swatch.

Common colors from RGB to HSL

Converted with the same code as the tool:

ColorRGBHSL
amber (stdlib.tools accent)rgb(255, 178, 36)hsl(39, 100%, 57%)
tealrgb(11, 114, 133)hsl(189, 85%, 28%)
bluergb(59, 130, 246)hsl(217, 91%, 60%)
greenrgb(22, 163, 74)hsl(142, 76%, 36%)
redrgb(220, 38, 38)hsl(0, 72%, 51%)
mid grayrgb(128, 128, 128)hsl(0, 0%, 50%)
blackrgb(0, 0, 0)hsl(0, 0%, 0%)
whitergb(255, 255, 255)hsl(0, 0%, 100%)

Frequently asked questions

Is RGB to HSL exact?

Yes, up to rounding: both describe the same 8-bit sRGB color, so converting back gives the same value.

Which format should I use in CSS?

HEX and rgb() work everywhere; hsl() is handy for shades written by hand; oklch() gives even lightness steps and wide-gamut colors in current browsers.

How do I write HSL with transparency?

Use a slash: hsl(39 100% 57% / 50%), or the older hsla(39, 100%, 57%, 0.5).

Report a problem