Blog
Unit converters

HSL to RGB converter

Enter a hue (0–360°), saturation and lightness (0–100% each) and the converter computes red, green and blue values (0–255), showing a live swatch of the resulting color.

Result

rgb() string —
Red (R) —
Green (G) —
Blue (B) —

All calculations run locally in your browser: parsing, chart, export. Disconnect the network and the page keeps working.

Facts and limits of this method

Hue (H) Wrapped modulo 360 — accepts any number
Saturation and lightness Clamped to the 0% to 100% range
Result range Each R/G/B channel is a whole number from 0 to 255
Formula Standard HSL → RGB algorithm via hue2rgb helper functions

When it misleads you

How it is calculated

Hue is wrapped into the 0–360° range and divided by 360; saturation and lightness are converted from percentages to fractions from 0 to 1.

Two helper values are computed from lightness and saturation, defining the brightness bounds for the current hue.

For each of the three channels (red, green, blue), a point on the color wheel is sampled, offset by a third of a turn relative to the hue — this gives three fractions from 0 to 1.

Each fraction is converted to the 0–255 range and rounded to a whole number — these are the final R, G and B values.

Questions and answers

What if I enter a hue above 360?

It's automatically wrapped modulo 360 — 400°, for example, is equivalent to 40°, since the color wheel is cyclical.

Why is the result always gray at 0% saturation?

That's a mathematical property of the HSL model: at zero saturation, hue has no effect, and all three RGB channels become equal to each other.

Will the result match if I convert it back to HSL?

Almost always, but rounding RGB to whole numbers can produce a fraction-of-a-percent deviation from the original saturation and lightness values.

Is my data sent anywhere?

No, the whole calculation runs in your browser.

Related tools

All tools