About the Color converter
Colours on the web can be written in several formats. HEX (#78B84A) is compact and common in design tools, RGB (rgb(120, 184, 74)) lists the red, green and blue channels, and HSL (hsl(95, 44%, 51%)) describes hue, saturation and lightness, which makes it easy to create lighter or darker shades.
This converter takes a colour in any of these formats, returns all three, and shows a preview swatch.
How to use the Color converter
- Paste a colour into the editor, for example
#78B84A,rgb(120, 184, 74)orhsl(95, 44%, 51%). - Click Convert color or press Ctrl + Enter (Cmd + Enter on Mac).
- Check the preview swatch and the HEX, RGB and HSL values.
- Copy the format you need.
Examples
HEX to RGB and HSL
Input
#78B84AOutput
HEX #78B84A
RGB rgb(120, 184, 74)
HSL hsl(95, 44%, 51%)RGB to HEX
Input
rgb(59, 130, 246)Output
HEX #3B82F6
RGB rgb(59, 130, 246)
HSL hsl(217, 91%, 60%)Common errors and how to fix them
The HEX has 8 digits
The last two digits are alpha (opacity), as in #3B82F680 for 50%. In RGB that's rgb(59 130 246 / 50%).
Converting HSL back gives a slightly different HEX
HSL values are rounded to whole numbers, so one step can land on a neighboring color. Keep the original HEX or RGB value as the source of truth.
3-digit HEX like #FA0
Each digit is doubled, so #FA0 is #FFAA00. Both forms are valid CSS.
Good to know
- HEX can be 3 or 6 digits, with or without the
#. rgba()andhsla()are accepted, but the alpha (transparency) value is ignored in the result.- HSL values are rounded to whole numbers, so converting HSL to HEX and back can differ by 1.
Frequently asked questions
Which colour format should I use in CSS?
All three work in every modern browser. HEX is the most common, RGB is handy when you need transparency with rgba(), and HSL is easiest for adjusting lightness to build a palette.
What does a 3-digit HEX code mean?
It's a shorthand where each digit is doubled. #fa0 is the same as #ffaa00.
Why do some colours look different on another screen?
Screens differ in brightness, colour calibration and colour space. The numeric values are the same; how they look depends on the display.