RGB to HSL Converter
Enter red, green and blue, each from 0 to 255, and get the hue, saturation and lightness. rgb(255, 165, 0), the CSS color orange, is hsl(39, 100%, 50%).
#FFA500exactly orange
For example rgb(30, 144, 255) or 30 144 255
For example hsl(210, 100%, 56%)
This is the CSS color orange #FFA500
Pick visually and see the other formats
Use 3 or 6 digits, for example #1E90FF or 19F
For example cmyk(88%, 44%, 0%, 0%)
Recent colors
Colors you pick appear here. They stay on this device.
By the Hex Color Picker Team. Updated
How to convert RGB to HSL
- Enter the value as rgb(255, 165, 0) or as three plain numbers in the RGB box.
- Copy the hsl() value from the HSL box.
- Edit the HSL box to adjust the color, and the RGB values follow.
The math, step by step
Scale each channel to a number between 0 and 1 by dividing by 255. For rgb(255, 165, 0) that gives 1, 0.647 and 0. Let max be the largest (1) and min the smallest (0).
Lightness is (max + min) / 2, which is 50%. Saturation compares the spread to the lightness: with a spread of 1 and a lightness of exactly half, it is 100%. Hue depends on which channel is the maximum. Red is the largest, so hue = 60 x ((green - blue) / spread) = 60 x 0.647, about 39 degrees.
Reading hue in degrees
- 0 degrees is red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue and 300 is magenta.
- Orange at 39 degrees sits between red and yellow, a little over a third of the way across.
- When all three channels are equal the color is grey and the hue isn't defined. Tools show it as 0.
When to use the HSL version
HSL is the format for adjustments. Add 10 to the lightness for a hover state, subtract 20 for a pressed state, or shift the hue by 30 degrees to find a neighboring color. In RGB the same changes mean working out three new channel values every time.
Quick checks
Some conversions are easy to verify by eye. rgb(255, 0, 0) is hsl(0, 100%, 50%), rgb(0, 255, 0) is hsl(120, 100%, 50%) and rgb(0, 0, 255) is hsl(240, 100%, 50%). rgb(255, 255, 0), full red and green with no blue, is yellow at hsl(60, 100%, 50%). White is hsl(0, 0%, 100%), black is hsl(0, 0%, 0%), and any grey has 0% saturation. If your result disagrees with these patterns, check that you entered the channels in red, green, blue order.
Common questions
Is the conversion lossless?
The math is exact, but the HSL values are shown as whole numbers, so converting back can differ by one step in a channel.
Why is the hue 0 for greys?
Greys have no dominant channel, so there is no hue to report. The hue is shown as 0 by convention, and the saturation of 0% means it has no effect.