Color contrast checker
Pick a text color and a background color to get the WCAG contrast ratio and see whether it passes AA and AAA for normal text, large text and UI components. Free, and it runs in your browser.
How to use it
- Choose the Text color and the Background color, or type exact HEX values in the optional fields.
- Read the Contrast ratio and the pass or fail result for each WCAG level.
- Use the preview to judge how the text really looks, then adjust the colors until the checks pass.
Complete guide to color contrast and WCAG
Why contrast matters
Light gray text on white looks elegant on a designer's bright monitor and becomes unreadable on a phone in the sun, or for anyone with low vision or color blindness. Contrast is the difference in brightness between the text and its background, and it is the single most common accessibility failure on the web. The Web Content Accessibility Guidelines (WCAG 2.x) turn it into a number, the contrast ratio, so that you can test instead of guess. This tool computes the ratio for any two colors and tells you which WCAG levels they meet.
How the ratio is calculated
Each color is first converted to relative luminance, a measure of how bright it appears to the eye. Each red, green and blue value is scaled to 0 to 1, linearized with the sRGB curve, and combined as 0.2126 R + 0.7152 G + 0.0722 B, which reflects that the eye is far more sensitive to green than to blue. The ratio is then (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color and L2 the darker one. It does not matter which color is the text, the ratio is the same. The scale runs from 1:1 (identical colors) to 21:1 (black on white). Everything runs in your browser.
The thresholds the tool checks
| Level | Minimum ratio | Applies to |
|---|---|---|
| AA, normal text | 4.5:1 | Body text under 18pt (24px), or under 14pt (about 18.7px) if bold |
| AA, large text | 3:1 | Text of 18pt or more, or 14pt or more in bold |
| AAA, normal text | 7:1 | The stricter level for normal text |
| AAA, large text | 4.5:1 | The stricter level for large text |
| AA, UI components and graphics | 3:1 | Borders of inputs, icons, chart elements |
Most laws and policies that mention WCAG ask for level AA, so treat AA normal text as your everyday target.
Worked example
- Choose Text color
#767676on Background color#ffffff(or type them in the HEX fields). The ratio is4.54:1and 4 of 5 checks pass. It is the lightest pure gray that still passes AA for normal text on white, but it fails AAA for normal text. - Change the text to
#777777. The ratio becomes4.48:1. It looks almost identical, yet it fails AA for normal text and only passes the large text and UI rows, 2 of 5. - Try the default
#1f2937on white. The ratio is14.68:1and all 5 checks pass. - Try the blue
#3b82f6on white. The ratio is3.68:1: fine for large headings and icons, but not for body text.
The preview shows a normal paragraph, a large bold line and a bordered component in your colors so you can judge the real look.
Tips and common mistakes
- The shown ratio is never rounded up across a threshold: a true 4.497 is displayed as 4.49 and fails, exactly as an audit would treat it.
- If the optional HEX fields are filled, they replace the color pickers. They accept
#abcand#aabbcc; anything else shows an error. - Check states too: hover, focus, disabled placeholders and text over images or gradients need their own test, because this tool compares only two flat colors.
- Pure black on pure white (21:1) can feel harsh for long reading. A dark gray such as
#1f2937keeps a high ratio with less glare. - Contrast is one part of accessibility. It does not replace testing with real users and assistive technology.
Related tools
If a pair fails, adjust the lightness with the color converter and its HSL value, or start from a balanced scheme in the color palette generator. To read a color from a screenshot use the image color picker.
Questions
What contrast ratio do I need?
WCAG AA asks for 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold, and up). AAA asks for 7:1 and 4.5:1. UI components and graphics need at least 3:1.
How is the ratio calculated?
Each color is converted to relative luminance with the sRGB formula from WCAG 2.x, then ratio = (lighter + 0.05) / (darker + 0.05). The result goes from 1:1 to 21:1.
Why does 4.49 fail if it looks like 4.5?
The displayed value is never rounded up to reach a minimum. A ratio just under the minimum fails, exactly as an accessibility audit would treat it.
Does this replace a full accessibility audit?
No. Contrast is one part of accessibility. Text over images, gradients and hover states also need to be checked in context.