HEX to RGB

Convert a hex colour to rgb, hsl and back.

Every form of it

About this converter

Paste a hex colour and get it back as rgb, hsl, and the CSS line to use — plus, because it is nearly always the next question, whether white or black text will be readable on it.

All the hex forms are accepted: three digits, six, and the four- and eight-digit versions that carry transparency. So are rgb(), hsl() and the common CSS colour names, because a converter that only accepts one direction is an annoyance rather than a tool.

The contrast figures are WCAG ratios against pure white and pure black. Anything at 4.5:1 or above passes AA for normal-size text; 3:1 is the bar for large text. That number decides whether a button label is legible, and guessing it from the swatch is how inaccessible interfaces get built.

Frequently asked questions

What do the extra two digits in an 8-digit hex mean?

Transparency. #RRGGBBAA puts the alpha channel last, where ff is fully opaque and 00 fully transparent. It is well supported in current browsers. The four-digit form is its shorthand, the same way three digits shorthand six.

When would I use HSL instead of HEX?

When you want related colours rather than one colour. HSL separates hue from saturation and lightness, so a hover state is the same value with the lightness moved a few percent, and a palette is one hue rotated. Doing either in hex means arithmetic in your head.

What does the contrast number mean?

It is the WCAG contrast ratio, from 1:1 (identical) to 21:1 (black on white). Normal text needs at least 4.5:1 to pass AA, large or bold text 3:1, and AAA asks for 7:1. The figures here are against pure white and pure black — if your background is neither, the real ratio will differ.

Does what I paste get sent anywhere?

No. The conversion runs in your browser, on your own machine, which is why the result appears as you type. What you paste is not uploaded or logged.

Related tools