HSL Converter

Hex code—
RGB—
HSL—

How HSL Converter is calculated: HSL → RGB: chroma = (1 − |2L − 1|) × S, hue picks the channels; RGB → HSL: L = (max + min) / 2, S from the spread, H from the largest channel. #FF5733 = HSL 11°, 100%, 60%.

What is an HSL converter?

An HSL converter translates a colour between two descriptions: HSL, which is hue, saturation, and lightness, and RGB, which is red, green, and blue, plus the hex code. It works in both directions. Give it HSL 210 degrees, 100 percent, 50 percent and it returns RGB 0, 128, 255 and hex #0080FF. Give it RGB 255, 87, 51 and it returns HSL 11 degrees, 100 percent, 60 percent and hex #FF5733.

HSL is the way people think about colour. Hue is the position on the colour wheel, from 0 to 360 degrees. Saturation is how vivid the colour is, from grey to full colour. Lightness is how bright it is, from black to white. RGB is the way screens think about colour: three lights, each 0 to 255. The converter translates between the human description and the machine description.

This page has a mode switch at the top. Choose HSL to RGB and the three HSL boxes drive the result. Choose RGB to HSL and the three RGB boxes drive it. The defaults are set to the same colour in both directions, #0080FF, so switching modes at the start changes nothing, and you can see the two descriptions side by side.

Everything runs in your browser. The numbers you type never leave your device, and there is no account to create.

How HSL conversion works

Converting HSL to RGB starts from the lightness and saturation. Together they fix the chroma, which is the spread between the brightest and darkest channel. For HSL 210 degrees, 100 percent, 50 percent, the chroma is 1.0, the full range, because the lightness sits exactly halfway and the saturation is full. The hue then decides which channels get the chroma.

Hue is divided into six 60-degree sectors, one per pair of channels. A hue of 210 degrees is in the fourth sector, cyan to blue, so blue gets the full chroma, green gets half of it, and red gets none. Half of 255 is 127.5, which rounds to 128, so the three channels come out as RGB 0, 128, 255. That is the default colour on this page, hex #0080FF.

Converting RGB to HSL goes the other way. Take RGB 255, 87, 51: the largest channel is red at 255 and the smallest is blue at 51, so the lightness is halfway between them, 60 percent. The spread is wide, so the saturation is 100 percent. The hue works out to 10.59 degrees, which rounds to 11, because red is largest and green is a little higher than blue, which puts the colour just past red towards orange.

The grey case is the simplest of all. HSL 0 degrees, 0 percent, 50 percent has no saturation, so the hue is meaningless and every channel is the same: RGB 128, 128, 128, which is hex #808080, the middle grey. Any HSL colour with 0 percent saturation is a grey, and its lightness alone fixes the shade.

Hue, saturation, and lightness explained

Hue is the colour itself, measured as an angle around the wheel. Red is 0 degrees, yellow is 60, green is 120, cyan is 180, blue is 240, magenta is 300, and back to red at 360. The default colour here has a hue of 210 degrees, between cyan and blue, closer to blue, which is why it reads as a bright sky blue. Move the hue to 120 and the same saturation and lightness give pure green; move it to 0 and they give pure red.

Saturation is how much colour there is versus how much grey. At 100 percent the colour is as vivid as it can be. At 50 percent it is half grey, a muted version of the same hue. At 0 percent it is a pure grey, and the hue stops mattering entirely. The default colour is at 100 percent, which is why it looks so strong.

Lightness is how much light there is, from black at 0 percent to white at 100 percent. At 50 percent the colour is at its full strength. Below 50 it darkens towards black, and above 50 it lightens towards white. The default colour is at 50 percent, exactly full strength, which is why its brightest channel is 255.

The three work together in a way RGB does not. To make a lighter version of a colour in RGB you have to raise all three numbers by different amounts, which is guesswork. In HSL you raise the lightness by 20 and leave the rest alone. That is why designers think in HSL and convert to RGB only at the end. An image hue tool shifts hue the same way for a whole picture, an image saturation tool does the same for saturation, and an image contrast tool adjusts the gap between light and dark.

A worked example: three colours, both directions

First, the default, HSL to RGB: hue 210, saturation 100, lightness 50 converts to RGB 0, 128, 255 and hex #0080FF. The chroma is 1.0, the hue sits in the cyan-to-blue sector, green gets half the chroma, and 127.5 rounds to 128. That is the bright sky blue used as the default on this page.

Second, RGB to HSL: red 255, green 87, blue 51 converts to HSL 11 degrees, 100 percent, 60 percent and hex #FF5733. The largest channel is red, the smallest is blue, so the lightness is 60 percent and the saturation is full. The hue of 10.59 degrees rounds to 11, just past red towards orange, which is why the colour is a bright orange-red.

Third, the grey: hue 0, saturation 0, lightness 50 converts to RGB 128, 128, 128 and hex #808080. No saturation means no hue, so all three channels are equal, and the lightness of 50 percent puts them exactly halfway between black and white. It is the middle grey, and it is the same grey whatever hue you type, because saturation zero erases the hue.

One more, to show the wheel: hue 120, saturation 100, lightness 50 converts to RGB 0, 255, 0 and hex #00FF00, pure green. Hue 120 is exactly green on the wheel, full saturation means no grey, and 50 percent lightness means full strength. Every primary colour sits at a multiple of 60 degrees with full saturation and 50 percent lightness.

Who uses an HSL converter, and why

Web developers use it to build colour systems. A brand colour in HSL can be lightened for a hover state or darkened for a border by changing one number, the lightness, and the hue and saturation stay put. In RGB the same change means adjusting three numbers at once, which is slower and easier to get wrong.

Designers use it to check that two colours share a hue. A palette built from one hue at different lightnesses looks coherent, and the converter confirms the hue is the same number in each colour. A background color changer is the place to see a converted colour filling a whole page before committing to it.

Developers writing canvas or SVG code use it to generate colours on the fly. A chart that needs ten distinct colours can step the hue by 36 degrees each time, with saturation and lightness fixed, and the converter turns each step into RGB. That is how most chart libraries build their palettes, and the maths is the same as the maths on this page.

Content creators use it to match colours across tools. A video editor, a slide deck, and a website may each want a different format for the same brand colour, and the converter translates between them without changing the colour. The hex code it shows is the one to paste into a stylesheet, and the HSL numbers are the ones to remember.

HSL converter vs a colour picker

A colour picker and an HSL converter answer different questions. A picker starts from a hex code and shows you what the colour looks like, with all three formats side by side. A converter starts from numbers in one format and gives you the numbers in the other format. The picker is visual; the converter is numerical.

If you have a colour and want to see it, use the picker. If you have HSL numbers from a design file and need the RGB numbers for code, use the converter. If you have RGB numbers from an image editor and need the HSL numbers to build a palette, use the converter in the other direction.

The converter also has a trick the picker does not: the mode switch. It lets you hold a colour fixed in one format and edit it in the other, which is how you answer questions like what hue is this RGB colour, or what RGB is this HSL colour. The picker shows both, but it does not let you drive from either side.

In practice, the two tools sit next to each other. Pick the colour, read the HSL numbers, change the lightness by 20 to make a lighter version, and convert the result back to hex. That loop, picker to converter and back, is how most colour work is actually done. A SCSS calculator is the next step when a stylesheet needs the same colour in several places at once.

Common HSL mistakes

The first mistake is thinking hue 0 and hue 360 are different colours. They are the same point on the wheel: red. Hue wraps around, so 360 is 0, 400 is 40, and minus 30 is 330. This converter wraps the hue for you, so any number works, but a tool that does not wrap will give a wrong colour or an error.

The second mistake is expecting saturation to change the hue. It does not. Saturation only changes how much grey is mixed in. A colour at hue 210 and saturation 50 is the same sky blue as the default, just muted. If the colour looks wrong, the hue is wrong, not the saturation.

The third mistake is lightness at the extremes. At 0 percent lightness every colour is black, whatever the hue and saturation. At 100 percent lightness every colour is white. If a conversion returns black or white unexpectedly, check the lightness first: it is the number that overrules the other two.

The fourth mistake is rounding. Converting RGB to HSL and back can shift a channel by one, because HSL rounds the hue, saturation, and lightness to whole numbers. RGB 255, 87, 51 converts to HSL 11, 100, 60, and converting that HSL back gives RGB 255, 88, 51, one digit off, because the true hue is 10.59 and rounds to 11. That is rounding, not a bug, and it is invisible to the eye.

How to use this HSL converter

Pick a mode at the top: HSL to RGB and HEX, or RGB to HSL. In HSL mode, type the hue from 0 to 360, the saturation from 0 to 100, and the lightness from 0 to 100. In RGB mode, type the red, green, and blue values from 0 to 255. The results update instantly as you type.

The results show all three formats at once: the hex code, the RGB numbers, and the HSL numbers. Copy the format your tool wants. The hex code is what CSS wants, the RGB numbers are what image editors want, and the HSL numbers are what you use to build a lighter or darker version.

Switch modes to check a colour from the other side. The defaults are the same colour in both directions, #0080FF, so switching at the start changes nothing. Type a colour in one mode, switch to the other, and the numbers you typed are still there.

Everything runs in your browser. No sign-up, no account, no data sent anywhere. The numbers you typed never leave your device, and the page works offline once it has loaded.

Frequently Asked Questions

RGB 0, 128, 255 and hex #0080FF. It is a bright sky blue: hue 210 degrees sits between cyan at 180 and blue at 240, saturation 100 percent means fully vivid, and lightness 50 percent means full strength, so the brightest channel is 255.

HSL 11 degrees, 100 percent, 60 percent, and hex #FF5733. Red is the largest channel and blue is the smallest, so lightness is 60 percent and saturation is full. The hue works out to 10.59 degrees and rounds to 11, just past red towards orange.

The colour is a pure grey and the hue does not matter. HSL 0 degrees, 0 percent, 50 percent is RGB 128, 128, 128, the middle grey, and any other hue with 0 percent saturation and 50 percent lightness gives the same grey. Lightness alone fixes the shade.

Almost, but not always. HSL values are rounded to whole numbers, so a colour can come back one digit off in a channel — RGB 255, 87, 51 converts to HSL 11, 100, 60 and back to RGB 255, 88, 51, because the true hue is 10.59 and rounds to 11. The shift is invisible to the eye, and hex to RGB conversion is always exact.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.