HEX to RGB Converter (and HSL, with Color Preview)
Type a color code in HEX, RGB or HSL and get all three formats ready to paste into CSS, plus a preview and a contrast check. It runs in your browser.
Color code
Examples: #3B82F6, #f80, rgb(59, 130, 246), 59 130 246, hsl(217 91% 60%)
Converted
Preview and contrast
| Against | Ratio | AA large (3:1) | AA (4.5:1) | AAA (7:1) |
|---|---|---|---|---|
| White | 3.68:1 | Pass | Fail | Fail |
| Black | 5.71:1 | Pass | Pass | Fail |
How to convert a color code
- Type or paste a HEX, RGB or HSL code, or use the color box.
- Read the other formats under Converted.
- Press Copy next to the one you need.
How HEX, RGB and HSL relate
A HEX code like #FF8800 is three pairs of base 16 digits for red, green and blue. Each pair is a number from 0 to 255, so #FF8800 is rgb(255 136 0). HSL describes the same color as a hue angle, a saturation percentage and a lightness percentage, which makes it easier to tweak by hand. The short form #F80 doubles each digit, and 8 digit codes add an alpha channel for transparency.
Related tools
Pick a color by eye with the color picker or sample colors from a photo with the image color picker.
See also
- Pick a color visually with the color picker.
- Pull colors out of a photo with the image color picker.
Frequently Asked Questions (FAQ)
Type or paste the hex code, with or without the #. The RGB value appears straight away. Behind the scenes the six digits are split into three pairs (red, green, blue) and each pair is read as a number from 0 to 255. For example #FF8800 is rgb(255 136 0).
Type the color as rgb(255, 136, 0) or just 255, 136, 0. The tool turns each channel into two hex digits and joins them, so you get #FF8800.
Enter the hex code and read the HSL line. Hue is the angle on the color wheel (0 to 360), saturation and lightness are percentages. #FF8800 is hsl(32 100% 50%). You can also type an HSL value and get HEX and RGB back.
Yes. #F80 is short for #FF8800, each digit is doubled. 4 digit and 8 digit codes with an alpha (transparency) channel work too.
It shows the WCAG contrast ratio of your color against white and against black. Text needs at least 4.5:1 to pass AA (3:1 for large text) and 7:1 to pass AAA. Use it to pick text and background colors people can read.
HSL is shown rounded to whole numbers, and several RGB colors can round to the same HSL. The HEX and RGB values are exact.
No. The conversion runs in your browser and nothing is sent or stored.