Contrast Checker
Check text and background contrast against WCAG thresholds
What is Contrast Checker?
A contrast checker that computes the WCAG contrast ratio between a foreground and background colour and reports whether it clears AA (4.5:1) and AAA (7:1), applying the relaxed 3:1 and 4.5:1 thresholds to large text. The calculation runs entirely in the browser.
How to use Contrast Checker
- 1Set the foreground (text) colour and the background colour.
- 2Read the contrast ratio and the AA / AAA verdicts.
- 3Use the preview panel to sanity-check how it actually looks; small type depends far more on high contrast.
- 4When a pair fails, adjust lightness first rather than reaching for bolder or bigger text.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
// WCAG relative luminance
const luminance = ({ r, g, b }) => {
const f = (c) => {
const s = c / 255;
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
};
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
};
const ratio = (a, b) => {
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
return (hi + 0.05) / (lo + 0.05);
};Frequently asked questions
What contrast ratios do WCAG AA and AAA require?+
Body text needs at least 4.5:1 for AA and 7:1 for AAA. Large text — 18pt and above, or 14pt bold — is relaxed to 3:1 for AA and 4.5:1 for AAA. Graphical objects and user interface component boundaries need a minimum of 3:1.
Why does grey text so often fail contrast checks?+
Light greys sit close to white in relative luminance: #999 on white is only about 2.8:1, well short of 4.5:1. When you want to de-emphasise secondary information, it is safer to reduce the size or weight of the text than to fade the colour until it becomes unreadable.
Related tools
All toolsImage Compressor
Compress images in your browser — no uploads
Image Format Converter
Convert between PNG, JPEG, WebP, and AVIF
Image Resizer
Resize images to exact dimensions, with optional aspect lock
Image to Base64
Turn images into data URIs with ready-to-use snippets
Favicon Generator
Generate multi-size icons and a favicon.ico
SVG Optimizer
Strip SVG cruft without touching path data