Toolstia / Color converter and contrast checker
Convert colors and check contrast
Designers write colors in HEX, stylesheets often use rgb(), and tools like color pickers think in HSL. This page converts between the three and shows a live swatch, so you can paste one and copy the form you need. It also checks how readable white and black text would be on your color, with a result for each.
That makes it useful in two jobs: translating a brand color from a style guide into the format a stylesheet or design tool wants, and deciding whether a button or banner color is accessible before it goes live. The calculation is done in the page, using the formulas from the web accessibility guidelines, so the ratios match what most audit tools report for the same colors.
#0c6b6brgb(12, 107, 107)hsl(180, 80%, 23%)Text contrast (WCAG)
WCAG asks for at least 4.5:1 for normal text (AA) and 3:1 for large text.
How it works
- Type a color or use the picker.
- Copy the HEX, RGB or HSL value.
- Check the contrast results for white and black text.
Formats it understands
HEX such as #0c6b6b or #fff, rgb(12, 107, 107), and hsl(180, 80%, 24%). Values are rounded to whole numbers.
Contrast and WCAG
The contrast ratio compares how bright two colors are. WCAG asks for 4.5 to 1 for normal text (level AA) and 3 to 1 for large text. 7 to 1 reaches the stricter AAA level.
Why check contrast
Low contrast text is hard to read for many people, especially on phones in daylight. Checking before you pick a button or banner color avoids a redesign later.
Rounding
Converting between formats can shift a color by one step because of rounding. Keep the original value if you need an exact match.
Worked example with checked values
Take the teal #0c6b6b. In decimal it is rgb(12, 107, 107), and in HSL it is hsl(180, 80%, 23%). Against white text it scores 6.30 to 1, which passes the AA level for normal text, and against black text it scores 3.33 to 1, which passes only for large text. White text is the right choice on this color.
A yellow such as #ffcc00 is the opposite. White text on it scores 1.51 to 1 and fails badly, while black text scores 13.89 to 1 and clears even the strictest AAA level. Warm, light colors almost always want dark text.
How contrast is calculated
Each channel is scaled to 0 to 1 and converted to linear light, then combined with weights 0.2126 for red, 0.7152 for green and 0.0722 for blue to get relative luminance. The ratio is the lighter luminance plus 0.05, divided by the darker luminance plus 0.05. A ratio of 1 means identical brightness, and the maximum, black on white, is 21.
Green carries most of the weight because human vision is most sensitive to it, which is why a pure red like #ff0000 reaches only 4.00 to 1 against white and falls just short of AA for normal text, yet gets 5.25 to 1 against black.
The grade labels used on this page
A ratio of 7 or more is labelled AAA, 4.5 or more is AA, 3 or more is labelled AA large text only, and anything below 3 is labelled Fails. Large text in WCAG means at least 18 point regular or 14 point bold, which is about 24 or 18.7 CSS pixels.
The edges matter. Gray #777777 gets 4.48 to 1 on white and does not meet the 4.5 level, while #767676 gets 4.54 to 1 and does. Visually they are indistinguishable, which is why it is worth checking rather than trusting your eyes. Also keep in mind that the accessibility guidelines ask for 3 to 1 for meaningful graphics and input borders.
Why converted values can shift by one
HSL values are shown as whole numbers, and converting a whole-number HSL back to RGB rounds again. The teal above is a good test. Its HSL reads as 80% saturation and 23% lightness, but typing hsl(180, 80%, 24%) produces #0c6e6e, a slightly different color.
So treat HEX or RGB as the source of truth, and use the HSL form only for adjusting lightness or saturation by feel. Keep the original code in your design files instead of round-tripping it through another format.
Accepted input and what is not supported
You can enter 3-digit or 6-digit HEX with or without the hash, rgb() with values from 0 to 255 separated by commas or spaces, and hsl() with a hue in degrees and saturation and lightness as percentages. A hue of 360 or more wraps around.
Named colors, 8-digit HEX with transparency, rgba(), and newer color spaces are not read. The contrast check only compares your color with pure white and pure black. For a pair of two custom colors, such as gray text on a tinted background, you would need to calculate the ratio of those two colors specifically.
Questions
Does it support transparency?
Not yet. It handles solid colors only.
Does it support named colors like "red"?
Not yet. Use HEX, rgb() or hsl().
Is my data sent anywhere?
No. Everything runs in your browser.
Which format should I use in CSS?
All three work in any modern browser. HEX is the shortest and most common, rgb() is easier to read in code, and hsl() is convenient when you want to make a lighter or darker variant by changing one number.
What is the difference between AA and AAA?
AA is the level most commonly used as a target, with 4.5 to 1 for normal text. AAA asks for 7 to 1 and is mainly used for text where readability is critical, though few brand palettes meet it everywhere.
Does a passing ratio guarantee readable text?
No. It is a useful minimum, but thin fonts, small sizes, busy backgrounds and color vision differences can still make text hard to read.
Why does 3-digit HEX like #fff work?
Each digit is doubled, so #fff means #ffffff and #0c6 means #00cc66. The tool shows the full six-digit form.
Can I use the color picker?
Yes. The picker beside the text box sets the color, and the HEX, RGB and HSL values and the contrast results update together.