A WCAG color contrast checker that takes a text color and a background color and tells you the exact contrast ratio, then grades it against the AA and AAA thresholds for normal text, large text, and user-interface components. A live preview shows real headings, body copy, captions, and a bordered button rendered in your two colors, so you can see and measure readability at the same time. It is built for designers, developers, and accessibility reviewers who need a fast, trustworthy contrast number before shipping a palette.
How it works
Every color is parsed from hex (#rgb, #rrggbb, or 8-digit #rrggbbaa) or from an
rgb() / rgba() string into red, green, and blue channels. Each channel is converted to
linear light and combined into a relative luminance value using the official sRGB
coefficients (0.2126 R, 0.7152 G, 0.0722 B). The contrast ratio is then
(L_light + 0.05) / (L_dark + 0.05), which ranges from 1:1 for identical colors up to a
hard ceiling of 21:1 for black on white.
When you reduce the foreground opacity, the tool first alpha-composites the text color over the background, because semi-transparent text never reaches its raw color on screen — it measures the blended result instead. The pass/fail matrix compares the final ratio to the five WCAG cutoffs (4.5, 3, 7, 4.5, and 3) and marks each as a pass or fail. If a pair fails AA, the suggest passing foreground button tries pure black or white against your background and applies whichever clears 4.5:1. You can swap the two colors, save tested pairs as swatches, and copy a plain-text report for your design notes or a pull-request comment.
Example
Suppose your brand uses a mid grey #767676 for captions on a white #ffffff background.
The checker reports a ratio of about 4.54:1 — it scrapes past AA for normal text but
fails AAA. Lighten the grey to #999999 and the ratio drops to roughly 2.85:1, which
now fails AA entirely and would be illegible for many low-vision readers.
| Foreground | Background | Ratio | AA normal | AAA normal |
|---|---|---|---|---|
#000000 | #ffffff | 21.0:1 | Pass | Pass |
#1a1a1a | #ffffff | 17.4:1 | Pass | Pass |
#767676 | #ffffff | 4.54:1 | Pass | Fail |
#999999 | #ffffff | 2.85:1 | Fail | Fail |
#ffd500 | #000000 | 16.4:1 | Pass | Pass |
Drop the captions to a darker grey and the same row flips to a comfortable AAA pass. Because the math runs live as you type, you can dial in the lightest shade that still clears your target level in seconds — and everything stays in your browser.