Hex to HSL Converter

Convert hex codes to HSL for CSS and design systems, with RGB and CMYK values alongside.

Enter a valid Hex value, like #3B82F6

  • HSL
  • RGB
  • CMYK

How hex to HSL conversion works

A hex code is red, green and blue written in base 16. To get HSL, each channel is divided by 255, and the largest (max) and smallest (min) values decide the rest:

L = (max + min) ÷ 2
S = (max − min) ÷ (1 − |2L − 1|)
H = which channel is max, and how far the
    other two are from each other, in degrees

For #3B82F6, Tailwind's blue-500, that gives hsl(217, 91%, 60%). Values here are rounded to whole numbers, which is how most design tools show them.

Common colors in HSL

ColorHexHSL
White#FFFFFFhsl(0, 0%, 100%)
Black#000000hsl(0, 0%, 0%)
Red#FF0000hsl(0, 100%, 50%)
Orange#FFA500hsl(39, 100%, 50%)
Yellow#FFFF00hsl(60, 100%, 50%)
Green#008000hsl(120, 100%, 25%)
Blue#0000FFhsl(240, 100%, 50%)
Purple#800080hsl(300, 100%, 25%)
Pink#FFC0CBhsl(350, 100%, 88%)
Gray#808080hsl(0, 0%, 50%)

Questions

How do I convert a hex code to HSL?

Paste the hex code above and the HSL value appears instantly. By hand, turn the hex into RGB, then find hue from which channel is largest, lightness from the average of the largest and smallest channel, and saturation from how far apart they are.

Is HSL the same as hex?

They describe the same colors in different ways. Hex writes red, green and blue as base-16 numbers. HSL describes a color by its hue, how saturated it is and how light it is. Every hex code has an HSL equivalent, and browsers accept both.

Why use HSL instead of hex in CSS?

HSL is easier to adjust by hand. To make a lighter or darker shade, change only the lightness. To make a muted version, lower the saturation. That makes HSL handy for hover states, color scales and theme variables.

Should I write hsl(217, 91%, 60%) or hsl(217 91% 60%)?

Both work in every modern browser. The comma version is older and more familiar. The space-separated version is the newer CSS syntax and lets you add opacity with a slash, like hsl(217 91% 60% / 50%).

Landings
Landing Page Examples
Copyright © 2026. All rights reserved.