Color converter
Paste a color in any common format and get it back as HEX, RGB and HSL, ready to copy into CSS, a design tool or a brand guide. The contrast check tells you straight away whether white or black text is readable on it.
Loading the color converter. It needs JavaScript to run in your browser.
Loading the color converter. It needs JavaScript to run in your browser.
How to use the color converter
- Enter a colorPaste a HEX code such as
#0f6b5c, anrgb()value or anhsl()value, or use “Pick a color” to choose one visually. - Copy the format you needHEX, RGB and HSL update together. Click a field to select it or press Copy.
- Check the contrastThe two samples show white and black text on your color with the WCAG contrast ratio and whether it passes AA or AAA.
- Adjust if neededIf text fails the check, lower the lightness in the HSL value for white text or raise it for black text, and paste it back in.
At a glance
- Formats
- HEX, RGB and HSL, converted both ways
- Input
- Type any format or use the color picker
- Contrast
- WCAG ratio against white and black text, with AA and AAA results
- Output
- Copy each format with one click
- Privacy
- Runs in your browser
- Cost
- Free, no sign-up
Learn more
When to use each format
All three formats describe colors on screens in the sRGB color space, so choosing between them is about convenience, not accuracy.
| Format | Example | Best for |
|---|---|---|
| HEX | #0f6b5c |
Brand guidelines, design hand-off, short CSS values |
| RGB | rgb(15, 107, 92) |
Code that does math on channels, adding transparency |
| HSL | hsl(170, 75%, 24%) |
Creating lighter or darker shades, building palettes |
HSL is the format to reach for when you want variations. Its three numbers are hue (the position on the color wheel, 0–360), saturation (how vivid it is) and lightness (from black at 0% to white at 100%). Keep the hue and saturation and change only the lightness, and you get a family of tints and shades that clearly belong together, which is much harder to do by adjusting RGB numbers.
How the contrast check works
The ratio follows the WCAG 2 formula. Each color is converted to its relative luminance, a measure of perceived brightness that weights green most heavily and blue least, because human eyes are most sensitive to green light. The ratio is the lighter luminance plus 0.05 divided by the darker one plus 0.05, which gives a number from 1:1 (no contrast) to 21:1 (black on white).
A useful benchmark: the mid-grey #767676 on white scores 4.54:1, just above the AA threshold, which is why designers often call it the lightest grey you can use for body text on a white page. The default teal on this page, #0f6b5c, scores 6.41:1 with white text, comfortably passing AA but not AAA.
Matching colors from an image or a logo
If you have a logo file but no color codes, open it in any image editor and use the eyedropper to read the HEX value, then paste it here to get RGB and HSL. Be aware that compressed JPG images slightly shift colors around edges, so sample from the middle of a large flat area. Brand colors taken from a printed piece will never match exactly either: print uses CMYK inks, which cover a different range of colors from screens. For more background on how the three screen formats relate, read our guide to HEX, RGB and HSL.
Questions
Which color formats can I paste?
Three-, four-, six- and eight-digit HEX codes, with or without the #; rgb() and rgba() in both the comma syntax (rgb(15, 107, 92)) and the modern space syntax (rgb(15 107 92 / 50%)); and hsl() or hsla() with the hue in plain numbers or degrees. Named colors such as “teal” aren't supported.
What is the difference between HEX and RGB?
They describe exactly the same color. RGB lists the red, green and blue amounts as numbers from 0 to 255; HEX writes the same three numbers in base 16, two digits each.
Why does my color change slightly when I convert to HSL and back?
HSL values are usually written as whole numbers, and one percent of lightness is about 2.5 steps of a 0–255 channel. Rounding to whole percentages can shift a channel by one or two steps. The difference is invisible, but if you need an exact match, keep the HEX or RGB value as your source of truth.
What contrast ratio do I need for accessible text?
WCAG 2 level AA asks for at least 4.5:1 for normal text and 3:1 for large text (about 24 px regular or 19 px bold). Level AAA asks for 7:1 and 4.5:1. Most accessibility policies and laws refer to level AA.
What happens to transparency (alpha)?
Alpha is preserved in the HEX (as an eight-digit code), RGBA and HSLA outputs. The contrast check ignores transparency and assumes the color is fully opaque, because the real contrast depends on whatever is behind it.
Is the picked color sent anywhere?
No. Conversion happens with a few lines of math in your browser, so nothing you enter is uploaded.