Complete Guide to Color Contrast Checker: WCAG Accessibility Made Easy
Learn how to check and fix color contrast ratios for WCAG compliance. A complete tutorial for the Color Contrast Checker tool.
Free Interactive Tool
Color Contrast Checker
Check color contrast ratios for accessibility compliance
Table of Contents
Color contrast isn't just a design preference β it's a legal and ethical requirement. In the United States, the Americans with Disabilities Act (ADA) and Section 508 both reference WCAG contrast standards, and the European Accessibility Act of 2025 makes them mandatory across the EU. If your text doesn't meet a 4.5:1 contrast ratio against its background, real users with low vision, color blindness, or simply sitting in bright sunlight will struggle to read your content.
Our Color Contrast Checker calculates the exact contrast ratio between any foreground and background color and tells you instantly whether you pass WCAG 2.1 AA and AAA requirements. In this guide, you'll learn how to use the tool, understand the math behind contrast ratios, and build accessible color systems that hold up in the real world.
Why Use a Color Contrast Checker?
Accessibility failures most often hide in plain sight β the gray-on-gray text that looks "modern" but is unreadable, the brand color that fails on a white background, the button label that vanishes in dark mode. A contrast checker catches these issues before they ship:
- Legal compliance β ADA, Section 508, and the European Accessibility Act (EAA) all require WCAG 2.1 Level AA as a baseline. Non-compliant sites have been the target of thousands of demand letters and lawsuits.
- Real readability β The 4.5:1 threshold isn't arbitrary; it represents the contrast needed for users with ~20/40 vision (roughly the population average over age 45) to read text comfortably.
- Wider audience β Roughly 1 in 12 men have some form of color vision deficiency. Accessible color choices make your product usable for them without special effort.
- Better design hygiene β Consistent contrast levels create visual hierarchy that's clearer for everyone, not just users with disabilities.
Key Features of the Color Contrast Checker
1. Instant Contrast Ratio Calculation
Type or paste a foreground and background color in HEX, RGB, or HSL format. The tool computes the precise contrast ratio (e.g. 7.42:1) using the WCAG 2.0 relative luminance formula β the same algorithm automated accessibility auditors use.
| Color Pair | Foreground | Background | Ratio | Result |
|---|---|---|---|---|
| Black on White | #000000 | #ffffff | 21.00:1 | Maximum contrast |
| White on Black | #ffffff | #000000 | 21.00:1 | Maximum contrast |
| Dark Blue on Light Blue | #003d82 | #e3f2fd | 8.59:1 | Passes AAA |
| Dark Gray on Light Gray | #333333 | #f5f5f5 | 12.63:1 | Passes AAA |
| Purple on Yellow | #4a148c | #fff9c4 | 11.17:1 | Passes AAA |
| Tailwind Blue (text-blue-600) on White | #2563eb | #ffffff | 4.58:1 | Barely passes AA |
| Light Gray on Gray (Low Contrast) | #cccccc | #dddddd | 1.16:1 | Fails all |
2. WCAG 2.1 AA and AAA Compliance
The tool checks your pair against four separate thresholds and shows a clear pass/fail badge for each:
| Standard | Context | Minimum Ratio |
|---|---|---|
| WCAG AA | Normal text (< 18pt) | 4.5:1 |
| WCAG AA | Large text (β₯ 18pt) | 3.0:1 |
| WCAG AA | UI components & graphics | 3.0:1 |
| WCAG AAA | Normal text | 7.0:1 |
| WCAG AAA | Large text | 4.5:1 |
"Large text" is defined as 18pt (24px) regular or 14pt (18.66px) bold. UI components β buttons, form fields, icons β only need to meet the 3.0:1 graphics threshold, but aiming higher never hurts.
3. Color Presets Library
Skip the guesswork with a built-in library of common accessible pairs: Black on White, White on Black, Dark Blue on Light Blue, Dark Gray on Light Gray, Purple on Yellow, Green on Cream, Red on White, Orange on Dark Blue, and a deliberately failing "Low Contrast" example for comparison.
4. Swap, Randomize, and Reset
- Swap colors β Flip foreground and background with one click. The ratio stays the same, but this lets you quickly check the inverse pairing (e.g. text color on a colored button).
- Random accessible pair β Generates a guaranteed-passing color combination, useful for brainstorming palettes that are accessible by construction.
- Reset β Return to the default black-on-white baseline.
5. Screen Reader & Keyboard Support
The checker announces contrast changes via an aria-live region, every control is keyboard-navigable, and pass/fail results use role="alert" so assistive technology reports failures assertively. The tool practices what it preaches.
How to Use the Color Contrast Checker
Step 1: Enter Your Colors
In the Foreground Color field, type the color of your text (e.g. #2563eb). In the Background Color field, type the surface it sits on (e.g. #ffffff). Both fields accept HEX (#rrggbb), RGB (rgb(r, g, b)), and HSL (hsl(h, s%, l%)) formats β with or without the leading #.
Step 2: Read the Contrast Ratio
The tool instantly displays the contrast ratio (e.g. 4.58:1) and a visual progress bar showing where you fall between 1:1 (no contrast) and 21:1 (maximum, pure black on pure white).
Step 3: Check WCAG Compliance
Below the ratio, four badges report pass/fail for WCAG AA Normal, WCAG AA Large, WCAG AAA Normal, and WCAG AAA Large text, plus a separate badge for Graphical Objects (UI components, icons).
Step 4: Iterate or Apply a Preset
If you fail, either adjust your color manually or click Random Colors to get a fresh accessible pair. You can also switch to the Presets tab and pick from the curated library.
Understanding Contrast Ratios
The Relative Luminance Formula
Contrast ratio isn't just "how different the colors look." WCAG defines it mathematically. Each color is first converted to a relative luminance (L) between 0 (darkest black) and 1 (brightest white), then the two are compared:
Contrast Ratio = (L_lighter + 0.05) / (L_darker + 0.05)
The + 0.05 accounts for ambient light scatter in the eye and is why the maximum ratio is 21:1, not infinity. Relative luminance itself is computed from the sRGB channel values:
For each channel c β {R, G, B}:
if c_srgb <= 0.03928: c_linear = c_srgb / 12.92
else: c_linear = ((c_srgb + 0.055) / 1.055) ^ 2.4
L = 0.2126 * R_linear + 0.7152 * G_linear + 0.0722 * B_linear
The green coefficient (0.7152) is largest because the human eye is most sensitive to green light β which is why green-on-black always reads more clearly than blue-on-black at the same mathematical brightness.
Why 4.5:1?
The 4.5:1 threshold for AA normal text corresponds to an equivalent contrast of about 20/40 vision β roughly the average visual acuity of the population over age 45, and the threshold below which driving is restricted in many jurisdictions. The 7:1 AAA threshold corresponds to 20/80 vision, accommodating users with more significant visual impairments.
3:1 for "Large Text" and Graphics
For text at 18pt+ (or 14pt+ bold), and for UI components like button borders and focus indicators, the requirement drops to 3:1. Larger shapes are easier to distinguish at lower contrast because the eye integrates more light over a larger area.
Practical Use Cases
Validating a Brand Color Palette
Brand colors are often chosen by designers for aesthetic reasons, then fail accessibility. Run every brand-on-surface pair through the checker before publishing your design system:
/* Example: Tailwind-style utility classes */
.text-primary-on-white {
color: #2563eb;
background: #ffffff;
} /* 4.58:1 β passes AA, fails AAA */
.text-primary-on-surface {
color: #ffffff;
background: #2563eb;
} /* 4.58:1 β passes AA */
.text-primary-dark {
color: #1e40af;
background: #ffffff;
} /* 8.59:1 β passes AAA β */
If a brand color fails on white, darken it (increase L delta in HSL) until it passes, then document the accessible variant in your design tokens.
Designing Dark Mode
Dark mode is where most contrast failures happen. A brand blue that reads fine on white often becomes unreadable on a near-black surface. Check every text/background pair in both themes:
:root {
--text-primary: #1e40af; /* on #ffffff β 8.59:1 β */
}
.dark {
--text-primary: #93c5fd; /* on #0f172a β 9.23:1 β */
}
A common pattern: in dark mode, use the lighter (100β300 range) shade of a color for text on dark surfaces, rather than the 500β700 shade you'd use on light surfaces.
Accessible Form Placeholders
Browser-native placeholders often fail contrast guidelines because they render at ~50% opacity. Validate the actual rendered color:
/* Bad: default placeholder opacity gives ~2.5:1 on white */
input::placeholder {
color: #9ca3af;
} /* 2.85:1 β FAILS AA */
/* Good: darker placeholder, or raise opacity */
input::placeholder {
color: #6b7280;
} /* 4.83:1 β passes AA β */
Focus Indicators
Focus rings must meet the 3:1 graphics threshold against both the element they outline and the background behind them. This is one of the most commonly overlooked requirements:
/* Focus ring must be visible against the button AND the page background */
:focus-visible {
outline: 3px solid #2563eb; /* check against button color + page color */
outline-offset: 2px;
}
Use the Swap Colors button to test the focus-ring color against each adjacent surface in turn.
Best Practices for Accessible Color
- Design with tokens, not raw values β Define text and surface colors as semantic tokens (--text-primary, --surface-base) so you can audit contrast once per token pair, not per usage.
- Don't rely on color alone β Color should reinforce meaning, never carry it alone. Pair color changes with icons, text labels, or patterns so color-blind users aren't locked out.
- Test in both themes β Every text/surface pair needs separate validation for light and dark mode. A palette that passes in one often fails in the other.
- Aim for AAA where cheap β AA (4.5:1) is the floor. If hitting AAA (7:1) only requires a slightly darker shade, do it β the extra headroom helps users with uncorrected vision and those in bright environments.
- Automate the check in CI β Tools like axe-core, Pa11y, and Lighthouse can run the same WCAG checks in your test pipeline so contrast regressions are caught before deploy.
Start Checking Your Colors Today
Ready to make your interfaces readable for everyone?
π Try the Color Contrast Checker Now
Related Tools You Might Like:
- Color Converter β Convert between HEX, RGB, and HSL to find the exact shade that passes.
- Color Palette Generator β Generate complete palettes from a base color, with accessible variants built in.
- Color Blindness Simulator β Preview your UI through the eyes of users with color vision deficiencies.
Happy Building Accessibly!