HEX to HSL Converter

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free HEX to HSL converter. Convert hex colour codes to HSL, RGB and HSV for CSS, or turn HSL values back into hex, with a live colour preview.

HEX
0
RGB
0
HSV
0

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to use the hex to hsl converter

From HEX:

  1. Choose "HEX".
  2. Enter a hex colour code, with or without the #, such as #3366ff, or a three-digit shorthand such as #36f.

From HSL:

  1. Choose "HSL".
  2. Enter the hue from 0 to 360, and the saturation and lightness as percentages from 0 to 100.

The converter shows the colour as HSL, HEX, RGB and HSV, with a preview swatch.

Colour codes on the web

Web pages describe colours in several equivalent ways:

  • HEX codes, like #3366ff, write the red, green and blue values as pairs of hexadecimal digits, from 00 to ff (0 to 255).
  • RGB, like rgb(51, 102, 255), gives the same red, green and blue values in decimal.
  • HSL, like hsl(225, 100%, 60%), describes a colour by its hue, saturation and lightness.

All three describe exactly the same colours; they're just different ways of writing them. HEX is compact and common in design tools, while HSL is often easier for people to adjust.

What do hue, saturation and lightness mean?

  • Hue is the position on the colour wheel, in degrees: 0° is red, 60° yellow, 120° green, 180° cyan, 240° blue and 300° magenta, returning to red at 360°.
  • Saturation is how vivid the colour is: 100% is the purest version of the hue, and 0% is grey.
  • Lightness runs from 0% (black) through the pure colour at 50% to 100% (white).

This makes HSL intuitive for design tasks. To make a colour lighter, raise the lightness. To mute it, lower the saturation. To find a related colour, change the hue while keeping the others the same.

How the hex to hsl converter works

The converter first turns the hex code into red, green and blue values from 0 to 255, then scales them to 0 to 1. With the largest value M, the smallest m and their difference d = M − m:

Lightness = (M + m) ÷ 2

Saturation = d ÷ (1 − |2 × lightness − 1|), or 0 if d is 0

Hue depends on which channel is largest:

  • If red is largest: hue = 60 × ((green − blue) ÷ d mod 6)
  • If green is largest: hue = 60 × ((blue − red) ÷ d + 2)
  • If blue is largest: hue = 60 × ((red − green) ÷ d + 4)

Converting HSL back to RGB reverses these steps.

With the default colour, #3366ff:

  1. RGB: red 51 (33), green 102 (66), blue 255 (ff).
  2. Scaled: 0.2, 0.4 and 1.0.
  3. Lightness: (1.0 + 0.2) ÷ 2 = 0.6, or 60%.
  4. Saturation: 0.8 ÷ (1 − |1.2 − 1|) = 0.8 ÷ 0.8 = 100%.
  5. Hue: blue is largest, so 60 × ((0.2 − 0.4) ÷ 0.8 + 4) = 225°.

So #3366ff is hsl(225, 100%, 60%).

More examples

HEX RGB HSL
#ff0000 255, 0, 0 0°, 100%, 50%
#ff6600 255, 102, 0 24°, 100%, 50%
#1e90ff 30, 144, 255 about 210°, 100%, 56%
#808080 128, 128, 128 0°, 0%, 50%
#336699 51, 102, 153 210°, 50%, 40%

A worked example: HSL to HEX

A designer wants a dark green at hsl(120, 100%, 25%).

  1. Chroma: (1 − |2 × 0.25 − 1|) × 1 = 0.5.
  2. Red, green, blue before adjusting: 0, 0.5, 0.
  3. Adjustment: 0.25 − 0.5 ÷ 2 = 0, so the values stay the same.
  4. RGB: 0, 128, 0.
  5. HEX: #008000, the colour CSS calls "green".

Choose "HSL" in the hex to hsl converter and enter 120, 100 and 25 to check.

Building colour palettes with HSL

HSL makes it easy to create consistent sets of colours:

  • Tints and shades: keep the hue and saturation, and step the lightness, such as 90%, 70%, 50%, 30% and 10%, for a range from very light to very dark.
  • Muted versions: lower the saturation for backgrounds and borders.
  • Complementary colours: add 180° to the hue.
  • Analogous colours: move the hue by about 30° in each direction.
  • Triadic colours: use hues 120° apart.

Many design systems and CSS frameworks define their colour scales this way. Our color shades generator builds full scales from one colour.

HSV versus HSL

HSV (hue, saturation, value), sometimes called HSB (brightness), is a similar model used in many colour pickers, such as those in Photoshop and Figma. The hue is the same as in HSL, but saturation and value are defined differently: in HSV, the pure colour has 100% value, while in HSL it has 50% lightness. The hex to hsl converter shows HSV too, so you can match values between tools.

Who uses a hex to hsl converter

Web designers and front-end developers use it to write CSS. UI designers use it to build colour palettes and design tokens. Brand designers use it to document colours in several formats. Developers use it to create hover and disabled states by adjusting lightness, and students use it to learn colour models.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.

Accessibility

Lightness in HSL doesn't exactly match how bright a colour looks to the eye. Yellow at 50% lightness looks much brighter than blue at 50% lightness. When choosing text and background colours, check the contrast ratio rather than relying on HSL lightness alone. Our color contrast checker tests colour pairs against accessibility guidelines.

Common mistakes

  • Entering hue as a percentage instead of degrees.
  • Confusing HSL lightness with HSV value.
  • Assuming equal lightness means equal perceived brightness across hues.
  • Forgetting that rounding can shift a colour by one step when converting back and forth.

Using HSL in CSS

Modern CSS accepts HSL directly, so once the hex to hsl converter gives you a value, you can use it in your stylesheet. Recent CSS syntax allows spaces instead of commas, such as hsl(225 100% 60%), and an optional alpha value for transparency, such as hsl(225 100% 60% / 0.5) for 50% opacity. Older syntax, hsl(225, 100%, 60%) and hsla(225, 100%, 60%, 0.5), still works in all browsers.

A popular technique is to store the hue, saturation and lightness as separate CSS custom properties, then build colours from them. For example, a brand colour's hue can be stored once, and every shade in the design system generated by changing only the lightness. Switching to a dark theme can then be as simple as changing a few lightness values.

Hex shorthand and alpha

Three-digit hex codes are shorthand: #36f means #3366ff, with each digit repeated. Only colours whose pairs of digits are identical can be written this way. Eight-digit hex codes, such as #3366ff80, add an alpha channel for transparency, where 80 in hexadecimal is 128, about 50% opacity. The hex to hsl converter accepts the three- and six-digit forms; drop the last two digits of an eight-digit code to convert its colour.

Hover and focus states

Interfaces often need slightly different shades of the same colour for hover, active and focus states. With HSL, that's easy: lower the lightness by 5 to 10 percentage points for a darker hover state, or raise it for a lighter one, keeping the same hue and saturation. For example, a button in hsl(225, 100%, 60%) might use hsl(225, 100%, 52%) on hover. Convert the result back to hex with the hex to hsl converter if your design tool needs it.

Colour on different screens

The same hex code can look slightly different on different screens, because displays vary in brightness, colour accuracy and colour gamut. Wide-gamut displays can show more saturated colours than the standard sRGB space that hex codes assume. CSS now supports wider colour spaces too, such as Display P3, through newer colour functions. For most web work, hex, RGB and HSL in sRGB remain the standard.

Converting brand colours

Brand guidelines often list a colour in several formats: HEX and RGB for screens, CMYK for print, and sometimes a Pantone reference. If your guidelines only give HEX, the hex to hsl converter adds HSL and HSV, and our RGB to CMYK converter gives an approximate CMYK value, though professional printing should use the printer's colour profile.

Sources and further reading

  • HSL and HSV on Wikipedia: the colour models and their conversion formulas.
  • MDN Web Docs: hsl(), the CSS function and its syntax.
  • Web colors on Wikipedia: hex codes, named colours and colour formats on the web.

Frequently asked questions

How do I convert HEX to HSL?

Convert the hex to RGB, scale to 0 to 1, then calculate lightness, saturation and hue from the largest and smallest channels.

What is #3366ff in HSL?

hsl(225, 100%, 60%).

What does the hue number mean?

The colour's position on the colour wheel, in degrees: 0 red, 120 green, 240 blue.

Is HSL the same as HSV?

No. They share the hue, but define saturation and lightness or value differently.

Can CSS use HSL directly?

Yes. Browsers support hsl() colours.

Is the hex to hsl converter free?

Yes. It's free, needs no sign-up, and works in your browser.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep