Colour Contrast Checker

Enter a text colour and a background colour and the tool shows the contrast ratio and whether the pair passes WCAG 2.2 level AA and AAA for normal text, large text and interface parts. If it fails, it offers the closest colour that passes, keeping the hue. The check runs in your browser.

How to use the Colour Contrast Checker

  1. Pick the text colour and the background colour, or type their hex codes such as #767676.
  2. Read the ratio. It runs from 1:1 (no contrast) to 21:1 (black on white).
  3. Check the list: AA normal text needs 4.5:1, AA large text 3:1, AAA normal text 7:1, AAA large text 4.5:1, and interface parts such as borders and icons 3:1.
  4. If the pair fails, use the suggested colour. It is the passing colour closest to yours in lightness, with the same hue and saturation.

How the ratio is calculated

Each colour gets a relative luminance L between 0 (black) and 1 (white): L = 0.2126 R + 0.7152 G + 0.0722 B, where R, G and B are the channel values (0 to 1) after undoing the sRGB curve. A channel c at or below 0.04045 becomes c / 12.92; above it, it becomes ((c + 0.055) / 1.055) raised to the power 2.4. The ratio is (L lighter + 0.05) / (L darker + 0.05).

Worked example: white on pure blue #0000ff. White has L = 1. Blue has R = G = 0 and B = 1, so L = 0.0722. The ratio is (1 + 0.05) / (0.0722 + 0.05) = 1.05 / 0.1222 = 8.59:1, which passes AAA for normal text (7:1). Black on white is (1 + 0.05) / (0 + 0.05) = 21:1, the maximum.

The ratio is shown rounded down to two decimals, so a pair that is a hair under a limit never appears to pass.

What counts as large text and what the levels mean

WCAG treats text as large from 18 point (24 CSS pixels) regular or 14 point (about 18.7 pixels) bold. Large text can be a little lighter because the strokes are thicker, so AA asks 3:1 for it and 4.5:1 for normal text.

Level AA is the usual target and the one most accessibility laws and procurement rules point to. AAA asks 7:1 for normal text; it is worth meeting for long reading text, but WCAG itself notes that not every page can reach AAA everywhere.

Example: grey #767676 on white is 4.54:1, so it passes AA for normal text. One step lighter, #777777, falls just under 4.5:1 and fails, although the two look almost the same. That is why a checker beats the eye.

What the ratio does not tell you

It measures lightness difference only. It does not know your font weight, text size on screen, anti-aliasing, a background image or a gradient behind the text. Test text over images at the lightest and darkest spots.

Colour alone should never be the only way to show meaning, such as red for errors with no icon or words. Contrast is one part of accessible design, not all of it.

Frequently asked questions

What contrast ratio do I need?

For WCAG 2.2 level AA: 4.5:1 for normal text and 3:1 for large text and for interface parts such as input borders and icons. For AAA: 7:1 for normal text and 4.5:1 for large text.

Does the order of the two colours matter?

No. The ratio is the same whichever is the text and whichever is the background, because the formula always divides the lighter luminance by the darker one.

Does it work for dark mode?

Yes. Enter the light text and the dark background. Check each theme of your site as its own pair.

Why does the suggested colour look so close to mine?

It is the smallest change in lightness that reaches the target, with hue and saturation kept, so your palette still fits. If the change is too big for your design, change the background instead.

Is anything uploaded?

No. The colours stay in your browser tab.

Sources

Last reviewed