How to convert HEX to HSL
- Convert the HEX code to RGB, then divide each value by 255 to get numbers from 0 to 1.
- Lightness is the average of the largest and smallest of the three values.
- If they are equal, the color is grey: saturation and hue are 0. Otherwise saturation = (max − min) ÷ (1 − |2 × lightness − 1|).
- Hue depends on which channel is largest and is measured in degrees around the color wheel (red 0°, green 120°, blue 240°).
Why designers use HSL
HSL describes a color the way people think about it. The hue is the basic color, such as orange at about 24°; saturation says how vivid it is; and lightness says how close it is to black or white. To make a hover color slightly darker, you only lower the lightness, without touching the other two numbers.
That makes HSL popular for design systems and CSS themes. A whole palette can share one hue and step through lightness values, and every browser supports hsl() and hsla() in CSS.
About decimals
HEX codes have 16.7 million possible colors, while whole-number HSL values can describe fewer. To make sure a color converts back to exactly the same HEX code, this converter shows HSL with one decimal place when it is needed, such as hsl(0, 0%, 50.2%) for #808080. Rounding to whole numbers is fine for most design work, but it can shift the color by one step.
Building a palette from one HEX code
Once a brand color is in HSL, you can create a whole scale by changing only the lightness. For #2563eb, a strong blue at hsl(221, 83%, 53%), lightness steps of 95%, 85%, 70%, 53% and 30% give a pale background, a border, a hover color, the main color and a dark text color, all with the same hue. Keep saturation close to the original for a consistent look.
The converter's shades and tints below the tool do a similar job by mixing with black and white, if you prefer to pick a step visually.
HEX to HSL chart of common colors
HEX to HSL values for common colors| Color | HEX | HSL |
|---|
| Black | #000000 | hsl(0, 0%, 0%) |
| White | #ffffff | hsl(0, 0%, 100%) |
| Red | #ff0000 | hsl(0, 100%, 50%) |
| Lime | #00ff00 | hsl(120, 100%, 50%) |
| Blue | #0000ff | hsl(240, 100%, 50%) |
| Yellow | #ffff00 | hsl(60, 100%, 50%) |
| Cyan | #00ffff | hsl(180, 100%, 50%) |
| Magenta | #ff00ff | hsl(300, 100%, 50%) |
| Silver | #c0c0c0 | hsl(0, 0%, 75.3%) |
| Gray | #808080 | hsl(0, 0%, 50.2%) |
| Maroon | #800000 | hsl(0, 100%, 25.1%) |
| Olive | #808000 | hsl(60, 100%, 25.1%) |
| Green | #008000 | hsl(120, 100%, 25.1%) |
| Purple | #800080 | hsl(300, 100%, 25.1%) |
| Teal | #008080 | hsl(180, 100%, 25.1%) |
| Navy | #000080 | hsl(240, 100%, 25.1%) |
| Orange | #ffa500 | hsl(38.8, 100%, 50%) |
| Tomato | #ff6347 | hsl(9.1, 100%, 63.9%) |
Other colors: use the converter above or the Color Converter.