Color Contrast Checker — WCAG AA & AAA
Paste a text color and a background color to see the exact contrast ratio and whether it passes WCAG 2.1 AA and AAA — with a live preview and one-click fixes. No signup, runs entirely in your browser.
How it works
The checker follows the contrast algorithm published by the World Wide Web Consortium in WCAG 2.1. It is the same maths used by accessibility auditors, browser dev-tools, and design systems, and it is the standard referenced by the EU Accessibility Act, US Section 508, and the ADA. Four steps take a color pair to a verdict:
- Parse and flatten. Each input is parsed to 8-bit sRGB channels (hex, rgb(), hsl(), or a CSS name). If a color carries an alpha channel it is composited onto a solid color first — the background over white, the text over the background — because the WCAG luminance definition only applies to solid colors.
- Linearise each channel. Normalise a channel to
cs = c / 255, then apply the sRGB transfer function:cs / 12.92whencs ≤ 0.04045, otherwise((cs + 0.055) / 1.055) ^ 2.4. - Relative luminance. Combine the linear channels with the BT.709 weights:
L = 0.2126·R + 0.7152·G + 0.0722·B. Green dominates because the human eye is most sensitive to it. - Contrast ratio.
ratio = (L_lighter + 0.05) / (L_darker + 0.05), where the 0.05 term models ambient screen flare. The result runs from 1:1 (identical colors) to 21:1 (black on white).
The ratio is then compared against the fixed thresholds: 4.5:1 for normal text and 3:1 for large text at level AA (SC 1.4.3), 7:1 and 4.5:1 respectively at AAA (SC 1.4.6), and 3:1 for user-interface components and graphics (SC 1.4.11). Text counts as large at 18pt (≈24px) regular or 14pt (≈18.66px) bold, so picking a size and weight selects the right gate. To keep results trustworthy the same ratio is computed twice — once by the shared site color engine and once by an independent implementation of the W3C formula — and the two are asserted to agree to within 0.001 before the tool ships.
When a pair fails, the nudge to pass feature converts the color to HSL and binary-searches its lightness toward black or white (whichever raises contrast) until it reaches the next failing threshold, then reports the nearest compliant color. If no lightness on that axis can reach the target, it says so rather than offering a color that does not actually pass.
Worked examples
Frequently asked questions
Sources & references
- W3C WCAG 2.1 — SC 1.4.3 Contrast (Minimum), AA — 4.5:1 normal / 3:1 large
- W3C WCAG 2.1 — SC 1.4.6 Contrast (Enhanced), AAA — 7:1 normal / 4.5:1 large
- W3C WCAG 2.1 — SC 1.4.11 Non-text Contrast, AA — 3:1 for UI & graphics
- W3C WCAG 2.1 — definition of relative luminance
- W3C WCAG 2.1 — definition of contrast ratio
The thresholds and formulas on this page were last cross-checked against the live W3C Recommendation on 2026-06-08. Values are reviewed whenever WCAG publishes an updated Recommendation.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.