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
| RGB | HSL | |
|---|---|---|
| Notation | rgb(255 178 36), rgb(255, 178, 36) | hsl(39 100% 57%) |
| In CSS | all browsers | all browsers |
| Typical use | code that computes colors, canvas, image libraries | themes 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%)andoklch(… / 0.5)all carry it.
How to convert RGB to HSL
- Type or paste the RGB value in its line, or pick a color with the color picker.
- 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:
| Color | RGB | HSL |
|---|---|---|
| amber (stdlib.tools accent) | rgb(255, 178, 36) | hsl(39, 100%, 57%) |
| teal | rgb(11, 114, 133) | hsl(189, 85%, 28%) |
| blue | rgb(59, 130, 246) | hsl(217, 91%, 60%) |
| green | rgb(22, 163, 74) | hsl(142, 76%, 36%) |
| red | rgb(220, 38, 38) | hsl(0, 72%, 51%) |
| mid gray | rgb(128, 128, 128) | hsl(0, 0%, 50%) |
| black | rgb(0, 0, 0) | hsl(0, 0%, 0%) |
| white | rgb(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).