The tool shows one color in three formats: HEX, RGB and HSL. Change any of them and the others follow. You can also click the Color Picker to choose a color with your browser's own color window. The large bar at the top shows the current color. A checked pattern shows through it when the color is see-through.
#FF5733. Upper or lower case both work, and the # sign is optional. Codes with 3, 4, 6 or 8 digits are accepted.Under the boxes, one line shows the color as CSS in all three formats. The three Copy buttons give you the same text. Copy HEX gives the full code in lower case, like #ff5733. Copy RGB gives rgb(255,87,51). Copy HSL gives hsl(11,100%,60%). When opacity is below 100%, you get #ff573380, rgba(255,87,51,0.5) and hsla(11,100%,60%,0.5) instead.
Let's follow #FF5733, a bright orange-red, through each format.
A HEX code is three pairs of hex digits: red, green, blue. Each pair is a number from 00 to FF, which is 0 to 255. The first digit counts sixteens, and A to F mean 10 to 15.
First divide each value by 255, so they run from 0 to 1: red 1, green 0.341, blue 0.2. The largest is 1 and the smallest is 0.2.
The tool gives the same answer. Type #FF5733 and you will see R 255, G 87, B 51 and H 11, S 100, L 60.
Now type 11, 100 and 60 into the H, S and L boxes. The tool works out RGB again and gets rgb(255, 88, 51), or #ff5833. Green is 88, not 87. The real hue was 10.6°, and the tool rounded it to 11. There are 16,777,216 RGB colors. We counted the colors that whole-number HSL values can make with this tool: only about 2 million of them. So if you need one exact color, keep the HEX or RGB value as your main copy. When you type in the HEX or RGB boxes, the RGB values stay exact. Only typing in the H, S or L boxes works RGB out again from the rounded numbers.
A 3-digit code is a short way to write a 6-digit one. Each digit is doubled: #abc means #aabbcc, which is rgb(170, 187, 204) and hsl(210, 25%, 73%). #fff is white and #000 is black. The tool reads 3-digit codes and fills in the RGB and HSL boxes. When you leave the HEX box, it writes the code out in full as #aabbcc, and Copy HEX copies that full form. A 4-digit code like #f008 works the same way, with the last digit for opacity.
A few things to know when you type a code:
# sign is optional. ff5733 and #ff5733 give the same color.#ff573 with only 5 digits, the other boxes keep the last good color. A short note tells you what is missing. A letter that is not a HEX digit, such as g, is named in the note.CSS also allows 8-digit HEX codes, where the last pair is the opacity. The tool reads that last pair and shows it in the Opacity % box. In #ff573380, 80 is 128 out of 255, which is about 50%. So the tool shows Opacity 50 and gives rgba(255,87,51,0.5) and hsla(11,100%,60%,0.5). You can also go the other way: type 50 in Opacity % and the HEX code gets 80 at the end.
The opacity is shown as a whole percent, and in rgba() with two decimal places. That is a little rounded. 128 out of 255 is really 50.2%. Browsers turn 0.5 back into 128, so the color looks the same.
In RGB, making a color lighter means changing all three numbers. In HSL you keep the hue and saturation and change only the lightness. Here are shades of our orange-red made that way in this tool:
| Color | HSL | HEX from the tool |
|---|---|---|
| hsl(11, 100%, 30%) | #991c00 | |
| hsl(11, 100%, 40%) | #cc2500 | |
| hsl(11, 100%, 60%) | #ff5833 | |
| hsl(11, 100%, 80%) | #ffac99 | |
| hsl(11, 100%, 90%) | #ffd5cc |
The other two numbers are useful too. Lower the saturation to get a softer color: hsl(11, 50%, 60%) is #cc7966, and at 0% you get plain gray, #999999. Add 180 to the hue to get the opposite color on the color wheel: hsl(191, 100%, 60%) is #33daff, a light blue.
The same L value does not mean the same brightness to the eye. Pure yellow hsl(60, 100%, 50%) and pure blue hsl(240, 100%, 50%) both have 50% lightness. But on a white background, yellow has a contrast ratio of only 1.07 to 1, and blue has 8.59 to 1. The WCAG accessibility guidelines ask for at least 4.5 to 1 for normal text and 3 to 1 for large text. Our #FF5733 on white is 3.15 to 1: fine for a large heading, too low for body text. This tool does not check contrast, so use a contrast checker before you pick text colors.
The R, G and B boxes take whole numbers from 0 to 255. If you type something else, the tool uses the nearest allowed value and tells you. For example, 300 in the R box gives a note that says Using 255, and 12.8 is rounded to 13. When you leave the box, it shows the value that was used. Opacity works the same way from 0 to 100, H from 0 to 360, and S and L from 0 to 100. If a box is empty, the other boxes keep the last good color until you type a number.
Split the code into three pairs and turn each pair into a number from 0 to 255. Multiply the first digit by 16 and add the second, where A to F mean 10 to 15. For #FF5733: FF = 255, 57 = 87, 33 = 51, so the color is rgb(255, 87, 51).
The tool shows hue, saturation and lightness as whole numbers. When you type in the H, S or L boxes, it works out RGB again from those rounded numbers. For example, #FF5733 shows as hsl(11, 100%, 60%), and typing those values back gives #ff5833. Keep the HEX or RGB value if you need the exact color.
Yes. Each digit is doubled, so #F00 is read as #FF0000, which is rgb(255, 0, 0) and hsl(0, 100%, 50%). When you leave the HEX box, the code is written out in full as #ff0000, and Copy HEX copies that. The Color Picker also gets the full code, so it shows red.
Yes. Type an 8-digit code like #ff573380, or set the Opacity % box. The last HEX pair, 80, is 128 out of 255, so the tool shows 50% and gives rgba(255,87,51,0.5) and hsla(11,100%,60%,0.5). The small Color Picker cannot show opacity, so it shows the solid color.
Copy HEX copies the full code in lower case, like #ff5733. Copy RGB copies rgb(r,g,b) with no spaces, like rgb(255,87,51). Copy HSL copies hsl(h,s%,l%), like hsl(11,100%,60%). When opacity is below 100%, they copy #ff573380, rgba(255,87,51,0.5) and hsla(11,100%,60%,0.5). All of them can be pasted straight into CSS.
No. Pure yellow and pure blue both have 50% lightness in HSL, but yellow looks much brighter. On white, yellow has a contrast ratio of 1.07 to 1 and blue has 8.59 to 1. Use a contrast checker for text, not the L value.