What is Color Contrast Checking?
Color contrast checking measures how distinguishable a foreground color is from a background color. The Web Content Accessibility Guidelines — WCAG 2.1, published by the W3C — define specific contrast ratios that text and interactive elements must meet so that people with low vision or color vision deficiencies can read your content. The contrast ratio is a number between 1:1 (no contrast at all — white on white) and 21:1 (maximum contrast — black on white). WCAG Level AA requires a ratio of at least 4.5:1 for normal-sized text and 3:1 for large text. Level AAA raises those thresholds to 7:1 for normal text and 4.5:1 for large text. Large text is defined as 18pt (24px) regular weight or 14pt (18.66px) bold.
The math behind the ratio relies on relative luminance — a measure of how bright a color appears to the human visual system. The formula starts by converting each sRGB channel value to linear light. You take each 8-bit channel (0-255), divide by 255 to get a value between 0 and 1, and then apply a gamma correction: if the value is 0.04045 or below, divide by 12.92; otherwise, raise ((value + 0.055) / 1.055) to the power 2.4. This linearization step accounts for the nonlinear encoding of sRGB displays. Then you compute relative luminance as L = 0.2126 * R_linear + 0.7152 * G_linear + 0.0722 * B_linear. The contrast ratio between two luminance values L1 (lighter) and L2 (darker) is (L1 + 0.05) / (L2 + 0.05). Those 0.05 offsets prevent division by zero and account for ambient light reflected off the screen.
This tool calculates the contrast ratio between any two colors you provide and tells you immediately whether the pair passes WCAG AA, WCAG AAA, both, or neither — for both normal and large text. All calculations happen in your browser. You get instant feedback as you adjust colors, making it easy to iterate toward a combination that is both visually appealing and accessible to the widest possible audience.