Hue, saturation and lightness, briefly
HSL describes a colour the way a person tends to describe it out loud: what colour is it, how vivid, how light or dark. Hue is degrees around a colour wheel — 0 is red, 120 is green, 240 is blue, and it wraps back to red at 360. Saturation is how far the colour sits from a neutral grey at that same lightness, from 0% (grey) to 100% (fully vivid). Lightness runs from 0% (black) through 50% (the purest version of the hue) to 100% (white). Hex and RGB store the same information as three channel intensities; HSL stores it as three separate, independently adjustable ideas. That separation is the whole reason to convert in this direction: hex and RGB are what a colour picker hands you, but HSL is what you want once the task changes from "record this colour" to "make a version of this colour that's a bit darker" or "pick something 30 degrees around the wheel from this one."
Converting #ff6347 by hand
Hex to HSL goes through RGB first. #ff6347 is rgb(255, 99, 71). Lightness is the average of
the largest and smallest channel: the largest is 255, the smallest is 71, and (255 + 71) / 2 is
163, which as a share of 255 is about 64% — the l in hsl(9, 100%, 64%). Saturation compares
how far apart the channels are (184, from 71 to 255) against how central that lightness is; here
the two work out equal, giving 100%. Hue looks at which channel is largest — red, in this case —
and how far green sits from blue relative to that spread, landing at 9 degrees, just past pure
red toward orange.
Why you'd reach for HSL instead of hex
The payoff shows up the moment you want to adjust a colour rather than just record it. Take
hsl(9, 100%, 64%), the tomato red above, and change only the lightness:
| Lightness | Hex equivalent | Looks like |
|---|---|---|
| 20% | #660f00 | Near-black maroon |
| 40% | #cc1f00 | Deep brick red |
| 64% | #ff6347 | The original tomato red |
| 80% | #ffa899 | Light salmon |
| 95% | #ffe9e5 | Barely-tinted white |
Every row is the same hue and the same saturation — only lightness moved. Reaching the same five shades starting from hex would mean recomputing all three channel values five separate times, because hex has no channel that isolates "lighter" from "a completely different colour."
A second example, and where saturation goes to zero
#2ecc71, a common UI green, converts to hsl(145, 63%, 49%) — a hue in the green third of the
wheel, well saturated, and close to the midpoint lightness where hues look their most vivid. Compare
that with #333333, which converts to hsl(0, 0%, 20%): saturation is 0%, because red, green and
blue are all equal (51 each), so there is no colour to point a hue at. This tool reports 0 for hue
in that case by convention — any number would do, since at 0% saturation the hue channel has
nothing left to affect. It's worth remembering when you're scripting against HSL values pulled
from real UI colours: a hue of 0 might mean "red," or it might mean "grey, hue is meaningless
here," and only the saturation number tells you which.