Color Converter
Convert any CSS color between HEX, RGB, HSL and CMYK, with a color picker and WCAG contrast ratios against white and black.
Color Converter: the tool
Color
Formats
#663399rgb(102, 51, 153)rgb(102 51 153)hsl(270, 50%, 40%)cmyk(33%, 67%, 0%, 40%)rebeccapurpleContrast with white
8.41 : 1AA text passAAA text passAA large pass
Contrast with black
2.50 : 1AA text failAAA text failAA large fail
How to use Color Converter
- Type a color in any CSS format, such as #663399, rgb(102 51 153), hsl(270, 50%, 40%) or rebeccapurple, or pick one with the color picker.
- Every other format is shown below it, ready to copy.
- Check the contrast ratio against white and black to see which text color is readable on your background.
Example
rebeccapurple, the named color #663399, in every format the converter shows.
HEX #663399 RGB rgb(102, 51, 153) HSL hsl(270, 50%, 40%) CMYK cmyk(33%, 67%, 0%, 40%) Name rebeccapurple
About this tool
The same color can be written in several ways. HEX and RGB describe how much red, green and blue light the screen mixes. HSL describes it with a hue angle (0 to 360), saturation and lightness, which is easier to adjust by hand: to get a darker shade, lower the lightness. CMYK is the ink model used in printing.
HEX, RGB and HSL conversions are mathematically exact. HSL values are rounded to whole numbers for display, so converting back may differ by one step in a channel. CMYK here is the simple arithmetic conversion; real printing uses color profiles, so treat it as an approximation.
Contrast ratios follow WCAG 2.x. Normal text needs at least 4.5:1 to pass level AA and 7:1 for AAA, and large text needs 3:1 for AA. Transparency is ignored in the contrast calculation.
Contrast thresholds (WCAG 2.x)
| Level | Normal text | Large text and UI parts |
|---|---|---|
| AA | 4.5 : 1 | 3 : 1 |
| AAA | 7 : 1 | 4.5 : 1 |
Frequently asked questions
Which color formats can I enter?
Hex with 3, 4, 6 or 8 digits, rgb() and rgba() in both the comma and the space syntax, hsl() and hsla() with deg, rad, grad or turn units, any of the 148 CSS color names, and transparent.
Why does converting back and forth change a value slightly?
HSL and CMYK values are rounded to whole percentages for display. HEX and RGB are exact, but a round trip through rounded HSL can shift a channel by a point or two.
Is the CMYK result suitable for printing?
It is the standard mathematical conversion, with no color profile. Print shops convert with a profile for their inks and paper, so the printed color may differ.
What is the contrast ratio?
It compares the relative luminance of two colors, from 1:1 (identical) to 21:1 (black on white). WCAG uses it to decide whether text is readable. This tool reports the ratio of your color against white and against black.
What does the color name row mean?
It appears when your color is exactly one of the 148 named CSS colors. It is not a nearest-match search.
More developer tools
- #→HEX to RGB ConverterConvert hex color codes to RGB, one per line. Supports 3, 4, 6 and 8 digit hex, with or without the # sign.
- →#RGB to HEX ConverterConvert rgb() and rgba() colors, or plain r, g, b triples, to hex codes. Batch conversion with alpha support.
- cssCSS FormatterBeautify CSS with one declaration per line and consistent indentation. Media queries, nesting, custom properties and data URLs are handled.
- cssCSS MinifierRemove comments, whitespace and the last semicolon of every block from CSS. The result behaves exactly like the original.