Understanding WCAG Contrast Standards
The Web Content Accessibility Guidelines (WCAG) 2.1 define contrast ratios to ensure visual readability for users with low vision or color vision deficiencies.
WCAG 2.1 Requirements Overview
- WCAG AA (Minimum): Requires a contrast ratio of at least 4.5:1 for normal text (under 18pt/24px or 14pt/18.5px bold) and 3:1 for large text and essential UI components.
- WCAG AAA (Enhanced): Requires a contrast ratio of at least 7:1 for normal body text and 4.5:1 for large text.
- Relative Luminance: Calculated by converting sRGB values into linear color space according to standard CIE luminance metrics.
What happens in the page
hexToRgb() parses the colour, getLuminance() applies the WCAG definition — divide each channel by 255, linearise with the 12.92 divisor below 0.03928 and the 2.4 power above it, then weight the channels — and calcContrast() combines two luminances as L1 plus 0.05 over L2 plus 0.05. badge() compares that ratio against the 4.5 and 7 thresholds and labels the pair as passing or failing, with the large-text threshold applied separately.
Where it breaks down
WCAG 2.x only. The APCA model proposed for WCAG 3 produces different verdicts, particularly for light text on dark backgrounds, so a pair that passes here may still look weak. Translucent colours are not composited — you must supply the final rendered colour. Gradients, images and text shadows cannot be evaluated. The large-text thresholds assume you judge the font size and weight yourself.
Privacy: no data leaves this tab
Two colour values are turned into a ratio in memory. Nothing is stored, and no design system or brand asset is transmitted.
Frequently asked questions
What is the difference between AA and AAA?
AA needs 4.5:1 for body text and 3:1 for large text; AAA raises those to 7:1 and 4.5:1. Large text means roughly 18pt, or 14pt bold.
Why does it disagree with a design tool?
Different formula generations, or a different large-text rule. WCAG's published formula is the reference; older approximations drift at the extremes.
Can I check text over an image?
Not here. The tool needs two solid colours; sample the actual background colour from the image first.