🎨 Color Converter

Edit any field — HEX, RGB or HSL — and the others update instantly, along with a live preview.

How RGB becomes HSL

The three channels are scaled to 0-1, then lightness is the midpoint of the largest and smallest, and saturation is the spread between them normalised differently above and below mid-lightness:

max, min over (r, g, b);  d = max - min
L = (max + min) / 2
S = L > 0.5 ? d / (2 - max - min) : d / (max + min)

H depends on which channel is the max - the hue sector:
  max is R:  H = (g - b) / d + (g < b ? 6 : 0)
  max is G:  H = (b - r) / d + 2
  max is B:  H = (r - g) / d + 4
then H = H / 6 × 360

Take the default #3B82F6. As fractions that is r 0.2314, g 0.5098, b 0.9647, so max is blue, min is red and d is 0.7333. L is 0.598, and since that is above 0.5, S is 0.7333 / (2 - 0.9647 - 0.2314) = 0.912. Blue is the max, so H is (0.2314 - 0.5098) / 0.7333 + 4 = 3.620, and 3.620 / 6 × 360 = 217.2°. The tool rounds and shows hsl(217, 91%, 60%). Going the other way, HSL is rebuilt through the standard p/q helper, with each channel sampled a third of the circle apart.

Working with the fields

H, S and L are displayed as whole numbers. Editing an HSL field converts through rounded values, so a hex can shift by a digit or two on a round trip. Treat the hex as the authoritative value.

Frequently asked questions

What is #3B82F6 in RGB and HSL?

rgb(59, 130, 246) and hsl(217, 91%, 60%). The hex pairs 3B, 82 and F6 are just 59, 130 and 246 written in base 16.

Is HSL the same as HSB or HSV?

No. HSL's lightness is the midpoint of the brightest and darkest channel, so 100% is always white. HSV's value is the brightest channel alone, so 100% value is the most vivid version of the hue, not white.

Why do two colours with the same L look different in brightness?

HSL is a geometric remap of the gamma-encoded sRGB numbers, not a perceptual space. Yellow at 50% lightness looks far brighter than blue at 50%. For perceived brightness you need relative luminance, which weights the channels and linearises them first.