How to use the contrast checker
Enter a text color and a background color in any CSS format — hex, rgb(), hsl(), or oklch(). Pick the standard (WCAG 2.2 or the APCA preview) and, for WCAG, your compliance target (AA or AAA). Set the font size and weight so large-text rules apply correctly. If the pair fails, choose whether to adjust the text or the background and apply the suggested passing color in one click. Your settings are encoded in the URL, so any result is a shareable link.
The color science
WCAG 2.x contrast is the ratio (L1 + 0.05) / (L2 + 0.05), where L1 and L2 are the relative luminances of the lighter and darker colors in linearized sRGB. It ranges from 1:1 to 21:1, with no rounding. APCA instead estimates perceptual lightness contrast (Lc) and is sensitive to text size and weight — an Lc of 60 roughly corresponds to 24px normal or 16px bold body text. Scoring here uses colorjs.io, and the “suggest a passing color” feature walks OKLCH lightness rather than clipping RGB channels, so it preserves your hue.
Frequently asked questions
What contrast ratio do I need for WCAG 2.2 AA?
WCAG 2.2 Level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (≥24px, or ≥18.66px bold). User-interface components and meaningful graphics also need 3:1. Level AAA raises the bar to 7:1 for normal text and 4.5:1 for large text.
Is WCAG 2.2 or APCA the standard I have to meet?
WCAG 2.2 is the latest W3C Recommendation, but most laws still cite an earlier version: the ADA Title II rule and the EU's EN 301 549 reference WCAG 2.1 AA, and US Section 508 references WCAG 2.0 AA. The AA contrast thresholds are identical across 2.0, 2.1, and 2.2, so meeting 2.2 AA also satisfies the 2.1 and 2.0 contrast requirements. APCA (Accessible Perceptual Contrast Algorithm) is proposed for the future WCAG 3, which is still a W3C Working Draft and does not name it — so it is not normative. Use the WCAG version your jurisdiction requires, and treat the APCA score here as an experimental preview.
Why does the ratio not round up to pass?
WCAG defines no rounding for the contrast ratio, so a value of 4.49:1 does not meet the 4.5:1 AA threshold even though it looks close. This checker compares the exact computed ratio against the threshold.
How does 'suggest a passing color' work?
It adjusts only the OKLCH lightness of the color you choose to change — text or background — and re-scores until the result meets your selected target, then returns the nearest passing value. It keeps your original hue, and its chroma wherever the result stays in sRGB — chroma is reduced only if a lightness change pushes the color out of gamut — so the suggestion stays on-brand. The returned hex is verified to pass after 8-bit rounding.
Can I check contrast for OKLCH or wide-gamut colors?
Yes. You can paste hex, rgb(), hsl(), or oklch() values. Because both WCAG and APCA are defined on sRGB luminance, out-of-sRGB colors are mapped into sRGB before scoring. Semi-transparent text is alpha-composited over the background first, since contrast formulas are defined for opaque pairs.
Related tools
References
This tool’s color math is grounded in the following standards and primary sources.
- Web Content Accessibility Guidelines (WCAG) 2.2 — W3C Recommendation
- Understanding SC 1.4.3: Contrast (Minimum) — W3C WAI — the AA contrast-ratio definition
- WCAG 3.0 — W3C Working Draft — not normative (context for APCA)
- APCA — Accessible Perceptual Contrast Algorithm — Myndex Technologies — experimental, proposed for WCAG 3
- Color.js — Lea Verou & Chris Lilley (MIT)
Spotted an error? Let us know — reader corrections are the best review this site gets.