Hex to HSL Converter
Convert hex color codes to HSL (hue, saturation, lightness) and back. Also shows RGB, CMYK, and WCAG contrast against white and black.
Hex and HSL Primary Colors
| Color | Hex | HSL |
|---|---|---|
| Red | #FF0000 | hsl(0, 100%, 50%) |
| Green | #00FF00 | hsl(120, 100%, 50%) |
| Blue | #0000FF | hsl(240, 100%, 50%) |
| Gray | #808080 | hsl(0, 0%, 50%) |
| Cyan | #00FFFF | hsl(180, 100%, 50%) |
| Yellow | #FFFF00 | hsl(60, 100%, 50%) |
Frequently Asked Questions about the Hex to HSL Converter
What does HSL stand for?
HSL is hue, saturation, and lightness. Hue is an angle from 0 to 360 degrees on the color wheel (0 red, 120 green, 240 blue). Saturation is the color's intensity from 0 (gray) to 100 (pure color). Lightness is how light or dark it is from 0 (black) to 100 (white), with 50 being the pure hue. CSS writes it as hsl(11, 100%, 60%).
What is the formula for converting hex to HSL?
First parse the hex into integer R, G, B (0-255) and divide each by 255. Let max = max(R', G', B') and min = min(R', G', B'). Lightness L = (max + min) / 2. If max equals min the color is gray, so H = 0 and S = 0. Otherwise S = (max - min) / (2 - max - min) when L > 0.5, else (max - min) / (max + min). Hue depends on which channel is the max: red gives (G' - B') / d wrapped into 0-6, green gives (B' - R') / d + 2, blue gives (R' - G') / d + 4. Multiply by 60 to get degrees.
Why does my HSL roundtrip drift by a degree or two?
HSL and RGB live on different grids. RGB is a 256-step cube, HSL stores hue as a continuous angle then rounds to integers. Going hex (24-bit) to HSL (rounded integers) and back can shift a channel by one unit, which is invisible to the eye but visible in the numbers. The converter rounds both outputs to whole numbers, so expect at most a one-step drift on a roundtrip.
How do I lighten or darken a color with HSL?
Keep H and S the same and change L. To make a tint, raise lightness toward 100 (#ff5733 at L 60 becomes a pastel at L 85). To make a shade, drop lightness toward 0. This is why designers prefer HSL for theme palettes: every step in a color scale is a lightness change at fixed hue and saturation, which keeps the family consistent.
Why are HSL values outside 0-360 or 0-100 rejected?
This converter restricts hue to 0 through 360 and saturation and lightness to 0 through 100. CSS itself accepts hue angles outside that range and normalizes them around the color wheel. The narrower validation is a calculator input rule, not a general CSS limitation.
Related Calculators
More calculators in "Tech"
Password Strength CheckerOhm's Law CalculatorUUID GeneratorColor Contrast CheckerBase64 Encoder / DecoderBase64 Decoder
See all 98 calculators in "Tech"