RGB to HSL Converter
Turn RGB color channels into the HSL model used by designers for hue, saturation and lightness.
What the converter returns
You enter three channel values and get the same color described by hue in degrees, saturation as a percentage and lightness as a percentage. The defaults 255, 100 and 50 produce H 15° S 100% L 60%, the orange behind #FF6432.
All three outputs are rounded to whole numbers, so the result is what you would write in a stylesheet: hsl(15 100% 60%). The color is identical to the RGB input; only the description changes.
The formula
The channels are first normalised to the range 0 to 1 by dividing by 255, so the arithmetic works in fractions rather than bytes. Then max is the largest channel, min the smallest, and d = max − min is the spread. Lightness is the midpoint of the range, which is why pure black and pure white both sit at saturation 0.
The spread d drives the hue. When it is zero the color is grey and hue is undefined, so the formula returns 0. Otherwise the sector is chosen by which channel is largest: red for 0–60°, green for 120–180°, blue for 240–300°. The final term interpolates within that sector.
Worked example: 255, 100, 50
Normalise: red 1, green 0.392, blue 0.196. The maximum is 1 and the minimum is 0.196, so lightness is (1 + 0.196) ÷ 2 = 0.598, which rounds to 60%. The spread is 0.804.
Red is the largest channel, so the hue comes from the red sector: ((g − b) ÷ d) × 60 = (0.196 ÷ 0.804) × 60 = 14.6, which rounds to 15°. Saturation uses the denominator 2 − max − min, which is 1 − 0.196 = 0.804, so 0.804 ÷ 0.804 = 1, or 100%.
- Lightness: (max + min) ÷ 2 = 0.598 → 60%
- Spread: max − min = 0.804
- Hue: red sector, 14.6° → 15°
- Saturation: 0.804 ÷ 0.804 = 1 → 100%
That saturation result is not a coincidence. The blue channel bottoms out near 0 while red is at full, so the color sits on the edge of the gamut and reads as fully saturated at this lightness. Lower the red to 200 and saturation drops well below 100 percent.
Hue landmarks
| Hue | Color | RGB |
|---|---|---|
| 0° | red | 255, 0, 0 |
| 60° | yellow | 255, 255, 0 |
| 120° | green | 0, 255, 0 |
| 180° | cyan | 0, 255, 255 |
| 240° | blue | 0, 0, 255 |
| 300° | magenta | 255, 0, 255 |
The six landmarks sit 60 degrees apart, and each one is a pair of channels at full or zero. Between them the third channel ramps. The default 15° lands in the first sector, a quarter of the way from red toward yellow, which is why it looks like a warm orange rather than a yellow.
Saturation and lightness behave differently
Saturation is 0 for any grey, including black and white, and 100 for a color that has one channel at full and at least one at zero. Lightness is 0 for black, 100 for white, and 50 for the most vivid version of any hue. A pure red is 0° 100% 50% and a pastel version is the same hue at 80% lightness.
One color, three notations
The default color is 255, 100, 50 in RGB, #FF6432 in hex, and hsl(15 100% 60%) in CSS. Each notation is lossless at eight bits per channel, so converting between them and back returns the same color as long as you do not round the hue to an integer halfway through.
That rounding is the one place where information is lost. A hue of 14.6 degrees becomes 15, and converting 15 back gives 255, 102, 51 rather than the original. The error is one step per channel, invisible on screen but enough to fail a test that compares exact values.
Where HSL bites
- HSL is not perceptually uniform: 60% lightness in yellow and in blue look different even though the number matches
- Saturation is computed against lightness, so raising L toward 100% washes the color out even without touching S
- Hue wraps at 360°, so 350° and 10° are 20 degrees apart, not 340
- Rounding H, S and L to integers changes the color slightly on the way back
- Alpha is a fourth value in CSS, so hsl() with a slash notation is a different string even for the same color
The perceptual point matters most in design work. Two colors with the same S and L but hues 60 degrees apart do not read as equally bright, because the eye is more sensitive to green than to blue. Perceptual spaces such as LCH exist to fix that, and they are not the same as HSL despite the similar letters.
Why the model is useful anyway
HSL maps to the operations designers actually perform. To build a palette you hold hue and saturation and step lightness in fixed increments, which keeps a family of tints visually related. To mute a color you lower saturation; to darken it you lower lightness. In RGB both operations require changing all three channels by amounts that differ per color.
Grey, black and white
When all three channels are equal, the spread is zero and the result is 0° 0% with lightness set by the shared value. That gives black at 0%, mid grey at about 50%, and white at 100%. The calculator reports a hue of 0 for these cases because hue has no meaning without a spread, a convention shared with the CSS specification.
Range and precision
Inputs are rounded and clamped to 0–255, so a channel of 300 is treated as 255. Hue is reported between 0 and 359 degrees and the other two values between 0 and 100 percent, all as integers. Within that range the conversion is exact before rounding, and the only approximation is the final whole-number step.
Frequently asked questions
How do I convert RGB to HSL?
Normalise each channel by dividing by 255, take the maximum and minimum, set lightness to their average, and derive saturation from the spread. Hue comes from which channel is largest, plus an interpolation term.
What is 255, 100, 50 in HSL?
H 15° S 100% L 60%. Lightness is (1 + 0.196) ÷ 2, and the hue is a quarter of the way from red toward yellow.
Why is saturation 100% for that color?
Because the spread equals the denominator: blue is near zero while red is at full, so the color sits at the edge of the gamut for its lightness.
What hue is pure red?
0 degrees. Pure green is 120, pure blue is 240, and yellow, cyan and magenta fall at 60, 180 and 300.
What is the HSL of white?
0° 0% 100%. All three channels are equal at 255, so there is no spread and therefore no saturation or meaningful hue.
Does HSL describe the same colors as RGB?
Yes, both cover the same 16.7 million colors at eight bits per channel. HSL is a different coordinate system over the same cube, not a wider gamut.
Why does 350° to 10° look like a small change?
Because hue is circular. The two hues are 20 degrees apart going through 0, even though the arithmetic difference is 340.
How do I lighten a color in HSL?
Raise L. Ten percent steps give a predictable tint series. Above about 90% the color approaches white and saturation becomes hard to see.
Which is better for palettes, HSL or LCH?
LCH is perceptually uniform, so equal lightness steps look equal. HSL is simpler and universally supported in CSS, which is why it remains common for quick adjustments.
Method and sources
- HSL color model (hue, saturation, lightness) conversion from RGB.