Blog
Unit converters

RGB to HSL converter

Enter the red, green and blue channel values (0–255) and the converter computes the hue in degrees, saturation and lightness in percent, showing a live swatch of the color.

Your data never leaves this device

Result

hsl() string
Hue (H)
Saturation (S)
Lightness (L)

This page has no server side at all. The table you paste is parsed by JavaScript inside your own browser, the chart is drawn on a canvas element on your machine, and the export file is assembled locally. Nothing is uploaded, stored or written to any log. You can disconnect from the network after the page has loaded and everything will still work — which is the simplest way to verify the claim yourself.

Facts and limits of this method

Each channel's range 0 to 255 inclusive
Hue (H) 0 to 360 degrees
Saturation and lightness 0% to 100%
Rounding Every RGB and result value is rounded to a whole number

When it misleads you

How it is calculated

R, G and B values are normalized to the 0–1 range by dividing by 255.

Lightness is computed as the average of the highest and lowest of the three channels.

If the max and min are equal, saturation and hue are zero (gray); otherwise saturation is computed from the difference between max and min relative to lightness, and hue from which channel came out highest.

The resulting fractions are converted to degrees (0–360) and percent (0–100) and rounded to whole numbers.

Questions and answers

Why is the hue 0° for a gray color?

At zero saturation, hue is mathematically undefined — 0° is just a convention, any hue value looks the same at that saturation.

Is HSL more accurate than RGB?

No, it's just another way to describe the same color — both formats define the same point in color space.

Can I enter fractional RGB values?

Yes, but they're rounded to the nearest whole number in the 0–255 range before the calculation.

Is my data sent anywhere?

No, the whole calculation runs in your browser.

Related tools

All tools