An HSL to RGB converter changes a color from the way that designers tend to think about it into the numbers that screens use. HSL describes a color by its hue, its saturation and its lightness, while RGB says how much red, green and blue light to mix. Enter the three HSL values, and this HSL to RGB converter gives you the RGB and hex codes, along with a swatch so you can see the result. Switch the mode to go the other way, from RGB back to HSL. It's useful for CSS, design systems and any work that needs a precise color.
How to use the HSL to RGB converter
- Choose HSL or RGB.
- Enter the three values.
- Press Convert.
- Check the swatch, and copy the format that you need.
What do H, S and L mean?
HSL stands for hue, saturation and lightness. It's a way of arranging colors in a cylinder. The angle around the central axis corresponds to the hue, the distance from the axis corresponds to the saturation, and the height corresponds to the lightness.
| Part | Range | What it controls |
|---|---|---|
| Hue | 0–360 degrees | The basic color: 0 is red, 120 is green and 240 is blue |
| Saturation | 0–100% | How vivid the color is: 0% is gray |
| Lightness | 0–100% | How light it is: 0% is black, 100% is white and 50% is the pure color |
The formula
To convert HSL to RGB, first express saturation and lightness as values between 0 and 1. Next, work out the chroma:
C = (1 − |2L − 1|) × S
Find the second-largest component with X = C × (1 − |(H ÷ 60) mod 2 − 1|), and work out the offset with m = L − C ÷ 2. Depending on which sixth of the color wheel the hue falls in, C and X are assigned to red, green and blue. Finally, add m to each and multiply by 255.
A worked example
Take hsl(210, 50%, 40%). With S = 0.5 and L = 0.4, the chroma is (1 − |0.8 − 1|) × 0.5, which is 0.4. Hue 210 ÷ 60 is 3.5, so X is 0.4 × (1 − |1.5 − 1|), or 0.2. The offset m is 0.4 − 0.2, which is 0.2. A hue between 180 and 240 gives red 0, green X and blue C. Adding m gives 0.2, 0.4 and 0.6. Multiplying by 255 gives rgb(51, 102, 153), which is the hex code #336699.
Why use HSL?
RGB is how screens work, but it isn't very intuitive. If you want a slightly darker blue in RGB, you have to change all three numbers in just the right proportions. In HSL, you simply reduce the lightness and leave everything else alone. That makes it easy to build a family of related shades. Keeping the hue and saturation fixed and stepping the lightness gives you a tidy palette for buttons, borders and backgrounds. CSS supports both forms, so you can write whichever one is easier for you.
Common colors in both systems
| Color | HSL | RGB | Hex |
|---|---|---|---|
| Red | hsl(0, 100%, 50%) | rgb(255, 0, 0) | #FF0000 |
| Green | hsl(120, 100%, 50%) | rgb(0, 255, 0) | #00FF00 |
| Blue | hsl(240, 100%, 50%) | rgb(0, 0, 255) | #0000FF |
| White | hsl(0, 0%, 100%) | rgb(255, 255, 255) | #FFFFFF |
| Black | hsl(0, 0%, 0%) | rgb(0, 0, 0) | #000000 |
| Mid gray | hsl(0, 0%, 50%) | rgb(128, 128, 128) | #808080 |
Rounding and tiny differences
RGB uses whole numbers from 0 to 255, while HSL values can have decimals, so converting back and forth may shift a value by one. That's normal, and the difference isn't visible on the screen. If you need the same color in several places, choose one format as your source and copy that value everywhere. Hue is circular as well, so 360 and 0 describe the same red.
HSL and HSV aren't the same
HSV, also called HSB, is a similar model in which the third value is brightness. Design software often shows HSV values in its color pickers, and those numbers won't match HSL even when the hue is identical. Check which model your application uses. A color with 50% lightness in HSL is the pure hue, whereas in HSV, the pure hue has a value of 100%.
Using the color in CSS
Copy the result straight into your stylesheet. Each of these lines sets the same blue: color: hsl(210, 50%, 40%), color: rgb(51, 102, 153) and color: #336699. Choose the form that's the easiest for your team to read and adjust, and stay consistent throughout a project.
Building a palette with HSL
Here's a simple way of creating a set of matching colors. Pick your main brand color and find its HSL values. Keep the hue and saturation the same, and make a lighter version for backgrounds by raising the lightness to about 90%. Then make a darker version for text and hover states by lowering the lightness to around 25%. Because only one number changes, the shades look as though they belong together. You can also move the hue by 180 degrees to find the complementary color on the opposite side of the wheel, or by 30 degrees in either direction for gentler, analogous colors. Once you're happy with the set, convert each one to RGB or hex here, and save the values in your stylesheet so that your whole team can use them.
Common mistakes
- Confusing HSL with HSV. The numbers aren't interchangeable.
- Using 0–1 instead of percentages. Enter 50, not 0.5.
- Forgetting that lightness 100% is always white, whatever the hue.
Related color tools
Find a shade with the color picker, check readability with the color contrast checker, and tidy your code with the HTML formatter.
What next
Use this often? Add HSL to RGB to your Home screen.
Frequently asked questions
How does the HSL to RGB converter work?
It calculates chroma from saturation and lightness, assigns it by hue, and scales the result to 0–255.
What is hsl(210, 50%, 40%) in RGB?
It's rgb(51, 102, 153), which is #336699.
Can it convert RGB to HSL?
Yes. Choose RGB, and enter the red, green and blue values.
What does the hue number mean?
It's an angle on the color wheel: 0 is red, 120 is green and 240 is blue.
Why did a value change by one?
RGB uses whole numbers, so rounding can shift a value slightly.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.