Skip to content
everylittletool

HEX to HSL Converter

Convert a hex colour code to HSL (hue, saturation, lightness) for CSS.

Runs in your browser — nothing is uploaded

HEX

HSL

0–360°

0–100%

0–100%

RGB

0–255

0–255

0–255

#2F6FDE

HEX → HSL

hsl(218, 73%, 53%)

How to use HEX to HSL Converter

  1. 1

    Type a hex code such as #2F6FDE into the HEX field.

  2. 2

    Read the Hue, Saturation and Lightness values, and the hsl() result beside the swatch.

  3. 3

    Click Copy HSL to copy the value as CSS, or adjust Lightness to find lighter and darker versions.

About this tool

HSL is worked out from RGB. First scale red, green and blue to 0–1 and find the largest (max) and smallest (min). Lightness is (max + min) ÷ 2. If max equals min the colour is grey, with no hue or saturation. Otherwise saturation is (max − min) ÷ (1 − |2L − 1|), and hue depends on which channel is largest, measured in degrees around the colour wheel.

Worked example: #2F6FDE is rgb(47, 111, 222), or 0.184, 0.435 and 0.871. Max is 0.871 and min 0.184, so lightness is 52.7%. Saturation is 0.686 ÷ 0.945 = 72.6%, and because blue is largest, hue is 60 × ((0.184 − 0.435) ÷ 0.686 + 4) = 218°. In CSS that is hsl(218, 73%, 53%). HSL is handy for themes: keep the hue and saturation and change only the lightness to make tints and shades.

Questions people ask

What do the HSL numbers mean?

Hue is the position on the colour wheel from 0° to 360° (red, then green at 120°, blue at 240°). Saturation is colour intensity from 0% grey to 100% vivid, and lightness runs from 0% black to 100% white.

Why does converting HSL back to HEX sometimes change the code slightly?

HSL values are rounded to whole numbers, which can shift a channel by one step. The difference is not visible.

Can I use HSL in CSS?

Yes. All modern browsers support hsl(218, 73%, 53%) and the newer space-separated form hsl(218 73% 53%).

Similar shortcuts