Contrast Test
Test color contrast ratio per WCAG 2.1 standards. Check AA/AAA compliance for text accessibility with real-time preview and fix suggestions.
Normal text sample — The quick brown fox jumps over the lazy dog. (16px)
Large text sample (24px)
Bold 14pt sample (18.66px bold)
About
Insufficient color contrast is the most common accessibility violation on the web. The Web Content Accessibility Guidelines (WCAG 2.1) define minimum contrast ratios between text and its background: 4.5:1 for normal text (Level AA) and 7:1 for enhanced readability (Level AAA). Large text (≥18pt or ≥14pt bold) receives relaxed thresholds. Failing these ratios exposes organizations to legal liability under ADA, Section 508, and EN 301 549. This tool computes the exact contrast ratio CR from the relative luminance L of two sRGB colors using the W3C-specified linearization formula. It does not approximate. Results match the official WCAG reference algorithm to full floating-point precision.
The tool also generates the nearest compliant color when your pair fails a threshold. Note: this calculation assumes colors are rendered on a standard sRGB display. Transparency compositing against unknown backgrounds is not handled. If either color uses alpha, composite it against white first.
Formulas
The contrast ratio between two colors is derived from their relative luminance values. First, each sRGB channel is linearized from its gamma-compressed form:
where csRGB is the 8-bit channel value divided by 255. Relative luminance is then:
The contrast ratio CR is computed as:
where L1 is the greater luminance and L2 is the lesser. The ratio ranges from 1:1 (identical) to 21:1 (black on white). Variable definitions: csRGB = gamma-compressed channel value in [0, 1]; clin = linearized channel value; Rlin, Glin, Blin = linearized red, green, blue channels; L = relative luminance in [0, 1]; CR = contrast ratio.
Reference Data
| WCAG Level | Text Type | Min Ratio | Font Size Threshold | Applies To |
|---|---|---|---|---|
| AA | Normal text | 4.5:1 | < 18pt (24px) | Body copy, labels, inputs |
| AA | Large text | 3:1 | ≥ 18pt or ≥ 14pt bold | Headings, large UI text |
| AA | UI components | 3:1 | N/A | Icons, borders, focus indicators |
| AAA | Normal text | 7:1 | < 18pt | Maximum readability |
| AAA | Large text | 4.5:1 | ≥ 18pt | Enhanced large text |
| AA (1.4.11) | Non-text contrast | 3:1 | N/A | Graphical objects, charts |
| Common Color Pairs & Their Ratios | ||||
| Black on White | 21:1 | Maximum possible contrast | ||
| White on White | 1:1 | Minimum possible (invisible) | ||
| #777 on White | 4.48:1 | Fails AA normal by 0.02 | ||
| #767676 on White | 4.54:1 | Lightest gray passing AA normal | ||
| #595959 on White | 7.0:1 | Darkest gray just passing AAA | ||
| Navy (#003366) on White | 11.1:1 | Strong accessible dark blue | ||
| Red (#FF0000) on White | 4.0:1 | Fails AA normal | ||
| Green (#00FF00) on White | 1.37:1 | Extremely poor contrast | ||
| Blue (#0000FF) on White | 8.59:1 | Passes AAA | ||
| #757575 on #FAFAFA | 4.36:1 | Fails AA normal on near-white | ||