Color converter
Everything runs in your browser; nothing is sent or stored.
- In the "Color" field, enter a HEX code, an rgb(), hsl(), or hwb() value, or a CSS color name, such as tomato.
- You can also choose a color in the "Color picker" field, and its HEX code appears in the "Color" field.
- The "Result" section shows the detected format, the CSS color name when the color has one, and the value of the color in each format. CMYK values are an approximate calculation without a color profile. For print work, ask the print shop for the exact values.
- To copy a value, click "Copy" below the field of that format.
- The "WCAG 2 contrast" section shows the contrast ratio against each background, with "Pass" or "Fail" for each level. Large text is 24 pixels or more, or 18.66 pixels or more in bold. The ratio is rounded down, so 4.499 shows as 4.49 and does not pass the 4.5 threshold. For a color with transparency, the contrast is calculated after the color is placed over the background.
- To check against another background, enter a color in the "Background color to compare (optional)" field.
CSS color formats
A HEX code consists of the # sign and three pairs of hexadecimal digits, which represent the intensity of red, green, and blue in the range 00 to ff (0 to 255 in decimal). A fourth pair of digits, when present, sets the opacity of the color. In the short form, each digit is doubled, so #fff is the same as #ffffff. The RGB format specifies the same three values as decimal numbers. In the HSL format, a color is defined by its hue, in degrees on the color wheel (0 is red, 120 is green, and 240 is blue), and by its saturation and lightness as percentages, so you can easily create a lighter or darker version of the same color by changing only the lightness. In the HWB format, a color is defined by its hue and by the amount of white and black mixed into it.
OKLCH and CMYK
The OKLCH format is based on the OKLab color space, which is designed to match the way the eye perceives color. In HSL, yellow and blue at 50% lightness look very different in brightness, while in OKLCH, two colors with the same lightness value look similarly bright. That makes OKLCH convenient for creating a set of interface colors with consistent lightness, for example for buttons and messages. The CMYK format describes the amount of ink in the four printing colors: cyan, magenta, yellow, and black. A screen also displays colors that cannot be printed with ink, and the printed result depends on the paper and the printing press, so converting to CMYK without a color profile is only an approximation.
WCAG color contrast
The WCAG accessibility guidelines define a contrast ratio between the text color and the background color, calculated from the relative luminance of the two colors. The ratio ranges from 1:1, when the colors are identical, to 21:1, between black and white. Level AA requires a ratio of at least 4.5:1 for normal text and at least 3:1 for large text, and at the stricter level AAA, the requirements are 7:1 and 4.5:1. Level AA also requires a ratio of at least 3:1 for interface components and graphics that are essential for understanding the content, such as the border of a form field and icons. Sufficient contrast helps visitors with low vision, and also any visitor who uses a screen in strong sunlight or at low screen brightness.
Sample values for the "Color" field
#3b82f680a color with transparency: the fourth pair, 80, sets an opacity of about 50%.#fffthe short form of #ffffff, white.rgb(59 130 246 / 50%)space-separated syntax, with the opacity after the slash.hsl(217 91% 60%)a hue of 217 degrees, 91% saturation, and 60% lightness.rebeccapurplea CSS color name, whose code is #663399.#767676the lightest gray that passes level AA for normal text on a white background, with a ratio of 4.54:1.#595959the lightest gray that passes level AAA for normal text on a white background, with a ratio of 7:1.
Related tools
Color converter FAQ
Can I enter a color in OKLCH format?
The tool shows the color in OKLCH format, but it does not accept an OKLCH value in the "Color" field. The keywords transparent and currentcolor are not accepted either. The value of currentcolor depends on the text color of the element where it appears. Instead of transparent, you can enter a HEX code with zero opacity, such as #0000.
Why does converting from HSL to HEX and back not return exactly the same value?
In a HEX code and in the RGB format, each channel is a whole number from 0 to 255, so values calculated from HSL are rounded to a whole number. For example, hsl(217 91% 60%) becomes #3c83f6, and converting #3c83f6 back gives hsl(217.1, 91.2%, 60%). The difference is too small to see on screen.
How is the contrast of a color with transparency calculated?
A color with transparency looks different on different backgrounds, so the tool places it over each background and calculates the contrast from the resulting color. When the background color to compare also has transparency, the background is first placed over white.
Why does a color chosen in the color picker lose its transparency?
The browser color picker supports only colors without transparency, so when you choose a color, the "Color" field shows a 6-digit HEX code. To get a color with transparency, you can add two digits to the code, such as cc for 80% opacity.
What is the maximum length of a color value I can enter?
The field accepts up to 200 characters, in uppercase or lowercase. A value outside the range is corrected to the nearest limit: for example, rgb(300, 0, 0) is shown as rgb(255, 0, 0), and saturation or lightness above 100% is corrected to 100%.