Contrast ratio checker
WCAG contrast ratio between any two colours, with AA and AAA verdicts for normal and large text.
The formula
Contrast ratio compares the relative luminance of two colours on a scale from 1:1 to 21:1. WCAG fixes the computation: convert each channel to linear light, weight the channels 0.2126 red, 0.7152 green and 0.0722 blue to get relative luminance, then take (L1 + 0.05) ÷ (L2 + 0.05) with the lighter colour as L1.
That constant 0.05 is a flare term. It models light scattered by the screen and the room, and it is why pure black on pure white tops out at 21:1 rather than infinity.
What the thresholds mean
Level AA requires 4.5:1 for normal text and 3:1 for large text — 18 point, or 14 point bold. Level AAA raises those to 7:1 and 4.5:1. WCAG 2.2 also applies a 3:1 floor to non-text essentials such as focus indicators and the boundaries of controls, which is the criterion most often missed.
The ratio is symmetric: swapping foreground and background gives the same number. What it cannot tell you is whether the result is comfortable to read — it is a floor, not a target.