EN

HEX to HSL Converter

Enter a HEX code to get its hue, saturation and lightness. HSL makes it easy to build lighter, darker or more muted versions of a color.

#6D46D3
hsl(256.6, 61.6%, 55.1%)
HEX#6D46D3
RGBrgb(109, 70, 211)
HSVhsv(256.6, 66.8%, 82.7%)
OKLCHoklch(0.519 0.205 290.1)

Working

  1. R′ = 109/255 = 0.427, G′ = 70/255 = 0.275, B′ = 211/255 = 0.827
  2. Max = 0.827, Min = 0.275, Δ = 0.553
  3. L = (Max + Min) / 2 = 0.551 → 55.1%
  4. S = Δ / (1 − |2L − 1|) = 0.616 → 61.6%
  5. H = 256.6° → hsl(256.6, 61.6%, 55.1%)

How to use it

  1. Type or paste a HEX code.
  2. Read hue (0-360°), saturation and lightness (0-100%).
  3. Copy the hsl() value.

The HEX to HSL formula

  1. Convert HEX to RGB and divide each channel by 255 (R′, G′, B′).
  2. Max = the largest, Min = the smallest; Δ = Max − Min.
  3. Lightness L = (Max + Min) / 2.
  4. Saturation S = 0 if Δ = 0, otherwise Δ / (1 − |2L − 1|).
  5. Hue: if Max is R′, H = 60 × ((G′ − B′)/Δ mod 6); if G′, H = 60 × ((B′ − R′)/Δ + 2); if B′, H = 60 × ((R′ − G′)/Δ + 4).

Example: #6D46D3 → hsl(256.6, 61.6%, 55.1%).

Frequently asked questions

Why keep one decimal in HSL?

With whole numbers some colors cannot round-trip: converting back gives a neighbouring HEX code. One decimal is enough for every sRGB color to convert back exactly.

Is HEX the same color as RGB?

Yes. A 6-digit HEX code is the same three RGB numbers written in base 16: two digits each for red, green and blue. Converting between them never changes the color.

Related tools