Color Converter: Switch Between CSS Color Formats
Convert colors between HEX, RGB, and HSL with a live preview.
About Color Converter
Color Converter translates a color between HEX, RGB and HSL. Edit any of the three text fields, or use the color picker at the top left, and the other fields and the preview square follow immediately. The page opens on a blue, #0284c7, so you can see the three notations side by side before entering your own.
It comes up when a logo file gives a color as RGB but a stylesheet wants HEX, when a brand guide lists HSL and a design tool wants something else, or when you want a lighter or darker shade and the easiest way is to change the lightness in HSL. Freelancers matching a client's brand color between a logo and a website do exactly this.
Input is forgiving but limited. HEX must be six digits, with or without the #, and RGB and HSL expect whole numbers. There is no support for three-digit HEX such as #fff, transparency, named colors like red, or other models such as CMYK. Output is rounded to whole numbers, so converting back and forth can shift a value slightly.
How to use Color Converter
- Start from what you have: type a six-digit code in the HEX field (for example #0284c7), whole numbers in the RGB field (2, 132, 199) or the HSL field (200, 98, 39), or choose a color with the picker.
- Watch the other fields and the preview square update as you type.
- If a red message appears under the fields, the value was not accepted and the other fields still show the previous color. Retype it in the format shown in the field's placeholder.
- To make a shade lighter or darker, change the last number in the HSL field (lightness) and read the new HEX value.
- Select the text in the field you need and copy it with Ctrl+C; there is no Copy button here.
Tips for best results
- Three-digit HEX such as #fff or #09c is rejected. Write each digit twice yourself (#ffffff, #0099cc) before pasting.
- The RGB and HSL fields take the first three whole numbers they find. rgb(10, 20, 30, 0.5) works, but the alpha is dropped, and a decimal such as 1.5 or a percentage such as 50% is misread, so use plain integers.
- Keep hue between 0 and 360. A value of 360 behaves like 0, but values far above it, such as 720, are not wrapped correctly and give wrong colors. Saturation and lightness above 100 are capped at 100.
- HSL is shown in whole numbers, so some detail is rounded off. #0284c7 shows as hsl(200, 98%, 39%), and entering exactly that gives #0284c5.
- The picker's look comes from your browser and operating system, and it cannot choose a transparent color.
Frequently asked questions
Which color formats are supported?
HEX (#rrggbb), RGB (rgb(r, g, b)), and HSL (hsl(h, s%, l%)).
Can I pick a color visually instead of typing values?
Yes, use the color picker swatch and all three formats update automatically.
Can I convert a three-digit or eight-digit HEX code?
No. Only six-digit HEX is accepted, so the shorthand and the form with an alpha pair are rejected with a message. Write out the full six digits first.
Does it support transparency (alpha)?
No. If you type rgba(...) the alpha value is ignored and only the first three numbers are used, so the result is always opaque.
How do I make a color lighter or darker?
Enter the color, then raise or lower the last number in the HSL field. Higher lightness is paler, 100 is white and 0 is black. The HEX and RGB fields follow.
Does letter case matter in HEX codes?
No. #FF5733 and #ff5733 are the same, and the # is optional. When the tool writes a HEX value itself it uses lowercase.