Color Contrast (WCAG) Checker

How do I check color contrast?

How it is calculated

Enter two hex colors, as 3 or 6 digits with or without the #. Each red, green and blue channel is divided by 255 and linearized: c / 12.92 when c is at most 0.04045, otherwise ((c + 0.055) / 1.055)^2.4. Relative luminance is L = 0.2126 R + 0.7152 G + 0.0722 B. The ratio is (Llighter + 0.05) / (Ldarker + 0.05), so it does not matter which color is the text.

The tool then shows four checks from WCAG 2.2: AA for normal text (4.5:1), AA for large text (3:1), AAA for normal text (7:1) and AAA for large text (4.5:1), each as Pass or Fails, plus one summary level: AAA pass at 7:1 or more, AA pass at 4.5:1 or more, “AA (large text only)” from 3:1 and otherwise a fail. Large text is 18 pt or 14 pt bold and above. An invalid code, such as a non-hex letter or a wrong digit count, returns an “Invalid color code” message instead of a ratio.

Worked example

Gray #767676 on white #ffffff. The gray channel is 118/255 = 0.4627, which linearizes to ((0.4627 + 0.055) / 1.055)^2.4 = 0.1812, so L = 0.1812. White has L = 1. The ratio is (1 + 0.05) / (0.1812 + 0.05) = 1.05 / 0.2312 = 4.54. That clears 4.5 but not 7, so the result is 4.54:1 with an AA pass.

Try this example →

Common mistakes

  • Judging by eye. #777777 on white gives 4.48:1 and fails, while #767676 gives 4.54:1 and passes, though the two grays look identical.
  • Assuming a mid-tone brand blue is safe on white. #1a73e8 reaches only 4.51:1, barely over the AA line, and any lighter shade fails.
  • Applying the large-text row to body copy. The 3:1 and 4.5:1 allowances are only for text of 18 pt or larger, or 14 pt bold; ordinary paragraphs need the normal-text rows.
  • Typing a color name or an rgb() value. Only 3- or 6-digit hex codes are accepted, and anything else returns the invalid message.
  • Forgetting that a 3-digit code doubles each digit: #f80 means #ff8800, not #0f0800.

Sources

About this calculator

This tool calculates the WCAG contrast ratio between a foreground and background color, a value from 1:1 (identical colors, no contrast) up to 21:1 (pure black on pure white), computed from each color's relative luminance. It then checks that ratio against the AA and AAA accessibility thresholds for both normal and large text — AA needs 4.5:1 (3:1 for large text) and AAA needs 7:1 (4.5:1 for large text) — to say whether a given text-and-background combination is actually readable enough to meet accessibility standards. Large text means 18 pt or larger, or 14 pt bold.

It is used by web designers and front-end developers checking a color palette before shipping it, since low-contrast text is one of the most common accessibility complaints and can fail legal accessibility requirements in some jurisdictions. Accessibility auditors also use this same calculation when reviewing a website or app for WCAG compliance, and design systems often bake AA-passing color pairs directly into their component libraries to avoid the problem entirely.

Was this helpful?

You can pick up to 3 reactions.

Note from the editors

The verdict here shows four WCAG 2.2 checks: AA needs 4.5 for normal text and 3 for large text, AAA needs 7 and 4.5. A light gray like #949494 on white lands at 3.03 and clears only the large text row, while black on white reaches the top of the scale at 21.00. A ratio of 3 is also the usual bar for icons or input borders. Test the worst spot on gradients. Which color pair were you trying to rescue?

Comments

  • Be the first to comment.

Popular calculators

All Calculators