Contrast Ratio Checker
Test text and background color pairs against WCAG AA & AAA accessibility standards
Why Contrast Ratio Is the Foundation of Accessible Web Design
When a designer picks colors for a website, they are making a choice that will affect every single visitor — including the roughly 300 million people worldwide who live with some form of color vision deficiency, the one-in-three adults over 65 who experience age-related contrast sensitivity loss, and the far larger number of people reading on a glaring phone screen in direct sunlight. Contrast ratio is not a stylistic preference. It is the quantitative measure that separates a legible experience from an exclusionary one.
The Web Content Accessibility Guidelines (WCAG), published by the W3C, formalized contrast requirements that are now baked into accessibility laws in the European Union, the United States (Section 508 and ADA case law), Canada, Australia, and the UK. Understanding exactly what those numbers mean — and how to test any color pair in seconds — is an essential skill for anyone who ships digital products.
How the Contrast Ratio Is Actually Calculated
The contrast ratio between two colors is not simply the visual difference you perceive — it is derived from relative luminance, a perceptual model rooted in how the human eye responds to light. The formula computes a value between 1:1 (no contrast whatsoever, like black on black) and 21:1 (the theoretical maximum, achieved by pure black on pure white).
The process works in three stages. First, each RGB channel value (0–255) is converted to a linear light value by reversing the gamma encoding that monitors apply. Second, those linearized values are weighted and summed using the coefficients 0.2126 for red, 0.7152 for green, and 0.0722 for blue — weights that reflect the fact that the human eye is most sensitive to green wavelengths and least sensitive to blue. The result is the relative luminance (L) of that color. Finally, the luminance of the lighter color plus 0.05 is divided by the luminance of the darker color plus 0.05 (the 0.05 offset accounts for ambient flare in real viewing environments), and the result is expressed as a ratio like 4.58:1.
This is why two colors can look very different to a designer yet still fail contrast requirements. A vivid red (#ff0000) on a pure white background only achieves a 4.0:1 ratio — it fails WCAG AA for normal-sized text, despite appearing eye-catching. Conversely, a dark navy on a pale blue can feel almost monochromatic yet pass comfortably because both lie at similar luminance extremes.
WCAG AA vs AAA: What the Levels Actually Require
WCAG defines two compliance tiers most organizations target — AA and AAA — and both tiers have different requirements depending on the size and weight of the text.
AA (the legal baseline): Normal text (below 18pt or 14pt bold) needs a minimum contrast ratio of 4.5:1. Large text (18pt and above, or 14pt and above in bold) only requires 3.0:1, because larger glyphs are inherently easier to resolve at lower contrast. This distinction matters enormously in practice: a heading at 24px bold might pass AA at 3.5:1 while the body copy directly beneath it using the same color pair would fail.
AAA (the gold standard): Normal text must meet 7.0:1, and large text must clear 4.5:1. AAA is not mandated for entire pages — WCAG explicitly states it is "not possible to satisfy all Level AAA Success Criteria for some content" — but it represents best-practice accessibility for body copy on public services, medical information, legal documents, and any context where reading failure carries real-world consequences.
There is one important category WCAG does not regulate via contrast ratio: decorative text (logos, incidental imagery, CAPTCHA), text in inactive UI components, and text that is part of a picture where other content is present. Knowing these carve-outs prevents teams from chasing impossible compliance targets on elements that are intentionally exempt.
Common Mistakes Designers Make With Color Contrast
The most frequent error is testing color pairs in a design tool rather than in a purpose-built contrast checker. Design applications render colors under color management profiles that may not match what a browser outputs. A color pair approved at 4.6:1 in a design mockup might land at 4.3:1 in the actual browser because of profile mismatch. Always test the hex values that will ship in the CSS.
A second trap is what might be called the brand color problem. Marketing teams often lock in primary colors that look authoritative in isolation — a medium-saturated orange, a mid-tone teal, a corporate red — without realizing those colors sit in exactly the luminance range that produces the lowest contrast values. A 50% saturated color tends to be the hardest to pair accessibly with either a light or dark background. The fix is rarely to abandon the brand color; it is to shift the text or background slightly toward the extremes, or to use the brand color only for large-text contexts where the 3.0:1 threshold applies.
A subtler mistake is testing only the primary state of interactive elements. A button that passes at 5:1 in its default state may drop to 2.8:1 when hovered or disabled. WCAG 1.4.3 applies to all text in all meaningful states, not just the resting appearance.
Practical Workflow for Getting Contrast Right
Start at the token level, not the component level. Define your palette's semantic roles — surface, on-surface, primary, on-primary — and test every role against every surface it will appear on before writing a single line of UI code. This upstream approach eliminates the painful retroactive fixes that happen when contrast violations are caught in QA or, worse, in an accessibility audit after launch.
Document your ratios alongside your design tokens. A comment in your CSS variables file that reads /* on-surface-text: #1a1a2e on #f8f9fc → 17.2:1 AAA */ takes five seconds to write and saves hours of re-testing across sprints. When someone later changes the background in a brand refresh, that annotation flags exactly what needs to be re-verified.
For teams using dark mode, remember that luminance relationships invert but ratios do not automatically follow. A pair that passes in light mode at 6.5:1 may or may not produce an equivalent dark-mode pair just by swapping colors. Calculate both independently.
Beyond WCAG: What WCAG 3.0 Changes
The upcoming WCAG 3.0 standard (still in working draft as of 2025) introduces a new contrast model called APCA — Advanced Perceptual Contrast Algorithm — which replaces the current luminance-ratio approach. APCA accounts for factors the current model ignores: font weight, character size, and the non-linear nature of human perception at very small or very large text sizes. Under APCA, the binary pass/fail of AA and AAA is replaced by a Bronze/Silver/Gold scoring system.
For now, the WCAG 2.x AA/AAA standards remain the legal and practical benchmark everywhere. But teams building component libraries today should be aware that a transition is coming, and keeping contrast ratios comfortably above the minimums — rather than scraping by at 4.5:1 — creates natural buffer for future compliance without a design overhaul.
The bottom line is this: contrast ratio is not bureaucratic box-ticking. It is the single most impactful accessibility intervention available to a design team, requiring no assistive technology, no specialized markup, and no runtime overhead. It is a pure design decision with direct, measurable consequences for every human being who reads your interface.