What this color contrast checker does
The checker measures how well a text color stands out against a background color, using the contrast ratio defined in the Web Content Accessibility Guidelines (WCAG) 2. It tells you whether the pair passes AA and AAA for normal and large text and the 3:1 minimum for interface components, shows a live sample at 16 px and 24 px, and lists both colors as hex, rgb() and hsl(). When a pair fails AA for normal text, it suggests the nearest darker or lighter text color that passes.
How to check a color pair
- Pick the text color with the color picker, or type a hex code (#1a2b3c or #abc) or an rgb() value.
- Do the same for the background.
- Read the ratio and the pass or fail table. Results update as you type.
- If the pair fails, try the suggested color, or use Swap colors to test light text on a dark background.
How the contrast ratio is calculated
WCAG compares the relative luminance of the two colors, a measure of perceived brightness from 0 for black to 1 for white. Each sRGB channel is first converted to a linear value:
c = channel ÷ 255 linear = c ÷ 12.92 if c ≤ 0.04045 linear = ((c + 0.055) ÷ 1.055) ^ 2.4 otherwise
The channels are weighted by how sensitive the eye is to each one, with green counting most:
L = 0.2126 × R + 0.7152 × G + 0.0722 × B ratio = (L_lighter + 0.05) ÷ (L_darker + 0.05)
The ratio runs from 1:1 (identical colors) to 21:1 (black on white). The WCAG 2 text quotes the threshold as 0.03928, from an older sRGB draft; for 8-bit colors both thresholds give identical results, because no channel value from 0 to 255 falls between them.
| Requirement | Minimum ratio | WCAG criterion |
|---|---|---|
| Normal text, level AA | 4.5:1 | 1.4.3 |
| Large text, level AA | 3:1 | 1.4.3 |
| Normal text, level AAA | 7:1 | 1.4.6 |
| Large text, level AAA | 4.5:1 | 1.4.6 |
| UI components and graphics | 3:1 | 1.4.11 |
Large text means at least 18 point (24 CSS pixels) at regular weight, or at least 14 point (about 18.66 px) in bold. The ratio shown is truncated to two decimals rather than rounded, so a pair displayed as 4.50:1 really meets 4.5:1.
Worked examples
Gray text on white
#767676 on #ffffff gives 4.54:1 and passes AA for normal text. One step lighter, #777777, gives 4.47:1 and fails. #949494 gives 3.03:1, enough only for large text, and #959595 gives 2.99:1, which fails even that.
Pure colors
Blue #0000ff on white reaches 8.59:1 and passes AAA. Red #ff0000 on white is only 3.99:1, so red error text needs a darker shade such as #c00000 to pass AA.
A brand color as a button
White text on #2563eb gives 5.16:1, which passes AA. White on the green #16a34a gives 3.29:1: fine for a large button label, too low for small text.
Tips and common mistakes
- Check every state. Placeholder text, disabled buttons, links on hover and focus outlines are often the lowest-contrast parts of a page. Disabled controls are exempt from WCAG contrast, but placeholders that carry information are not.
- Text on images varies. Test against the lightest and darkest areas behind the text, or add an overlay.
- Transparency changes the color. The tool ignores alpha. For semi-transparent text, test the color it produces on its background.
- Passing is a floor. Thin fonts and small sizes read worse than the ratio suggests. Aim above the minimum for body text.
Limits and privacy
The checker implements WCAG 2.x, the version used in current accessibility law and audits. It does not compute APCA, the experimental method proposed for WCAG 3. It assumes sRGB colors and does not simulate color vision deficiencies. All calculations happen in your browser.