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

HEX
#3B82F6
RGB
rgb(59 130 246)
HSL
hsl(217 91% 60%)
RGB values
59, 130, 246

Preview and contrast

Text on white
Text on black
WCAG contrast of this color against white and black
AgainstRatioAA large (3:1)AA (4.5:1)AAA (7:1)
White3.68:1PassFailFail
Black5.71:1PassPassFail

How to convert a color code

  1. Type or paste a HEX, RGB or HSL code, or use the color box.
  2. Read the other formats under Converted.
  3. 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

Frequently Asked Questions (FAQ)

How do I convert HEX to RGB?

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).

How do I convert RGB to HEX?

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.

How do I convert HEX to HSL?

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.

Does it accept 3 digit hex codes?

Yes. #F80 is short for #FF8800, each digit is doubled. 4 digit and 8 digit codes with an alpha (transparency) channel work too.

What does the contrast check tell me?

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.

Why is my HSL value off by one?

HSL is shown rounded to whole numbers, and several RGB colors can round to the same HSL. The HEX and RGB values are exact.

Is my input uploaded?

No. The conversion runs in your browser and nothing is sent or stored.