What are HSL and RGB?
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. RGB gives the same three sRGB channels as decimal numbers from 0 to 255, plus an optional alpha.
Canvas code, game engines and LED strips take RGB numbers, while palettes are easier to design in HSL; this page is the bridge.
The color converter below starts from HSL and highlights RGB, next to HWB, LAB, LCH and CSS names.
HSL vs RGB
| HSL | RGB | |
|---|---|---|
| Notation | hsl(39 100% 57%) | rgb(255 178 36), rgb(255, 178, 36) |
| In CSS | all browsers | all browsers |
| Typical use | themes and shades in CSS | code that computes colors, canvas, image libraries |
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
- HSL and RGB 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 HSL to RGB
- Type or paste the HSL value in its line, or pick a color with the color picker.
- Read the RGB line, which updates as you type, and check the preview swatch.
Common colors from HSL to RGB
Converted with the same code as the tool:
| Color | HSL | RGB |
|---|---|---|
| amber (stdlib.tools accent) | hsl(39, 100%, 57%) | rgb(255, 178, 36) |
| teal | hsl(189, 85%, 28%) | rgb(11, 114, 132) |
| blue | hsl(217, 91%, 60%) | rgb(60, 131, 246) |
| green | hsl(142, 76%, 36%) | rgb(22, 162, 73) |
| red | hsl(0, 72%, 51%) | rgb(220, 40, 40) |
| mid gray | hsl(0, 0%, 50%) | rgb(128, 128, 128) |
| black | hsl(0, 0%, 0%) | rgb(0, 0, 0) |
| white | hsl(0, 0%, 100%) | rgb(255, 255, 255) |
Frequently asked questions
Is HSL to RGB 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 RGB with transparency?
Use a slash: rgb(255 178 36 / 50%), or the older rgba(255, 178, 36, 0.5); both mean 50% opacity.