Contrast Checker

Contrast ratio of text on a background, against WCAG AA and AAA.

About Contrast Checker

A contrast checker that gives the WCAG 2 contrast ratio between a text colour and a background, pass or fail for AA and AAA, and a fix when normal text fails.

How to use

  1. Set the text colour and the background with the swatches, or type a hex, rgb() or hsl() value. The ratio updates as you type.
  2. Read the ratio and the table: AA and AAA for normal and large text, and the 3:1 threshold for UI components and graphics.
  3. Check the sample block, which renders normal and large text in the chosen colours.
  4. If AA fails for normal text, the suggested colour is the nearest lighter or darker shade of the same hue that passes; Use it applies it. Swap exchanges the two colours.

What it does

  • Computes relative luminance per the WCAG 2.1 formula: each sRGB channel is linearised (divided by 12.92 below 0.03928, otherwise ((c + 0.055) / 1.055)^2.4) and weighted 0.2126 R, 0.7152 G, 0.0722 B. The ratio is (L1 + 0.05) / (L2 + 0.05) with the lighter colour on top, from 1:1 to 21:1.
  • Thresholds: AA needs 4.5:1 for normal text and 3:1 for large text (criterion 1.4.3); AAA needs 7:1 and 4.5:1 (1.4.6); user-interface components, focus indicators and meaningful graphics need 3:1 (1.4.11). Large text means at least 24px, or 18.66px bold.
  • Alpha is ignored. A semi-transparent colour has to be flattened onto its actual background before the ratio means anything, so pass the resulting opaque colour.
  • The suggestion keeps the hue and saturation of the text colour and steps its lightness one percent at a time away from the background until 4.5:1 is reached.

Example

#777777 on #FFFFFF → 4.48:1
AA normal: Fail · AA large: Pass · AAA normal: Fail · AAA large: Fail · UI: Pass
Suggested text colour: #757575 (4.61:1)

Privacy

The ratio is computed in the browser. No request is made, and nothing is stored.

Frequently asked questions

What contrast ratio is needed for WCAG AA?
At least 4.5:1 for normal text and 3:1 for large text (24px, or 18.66px bold). AAA raises these to 7:1 and 4.5:1. Buttons, form borders, focus rings and icons that carry meaning need 3:1 against adjacent colours.
Why does #777 fail on white?
Medium grey #777777 on white gives 4.48:1, just under the 4.5:1 AA threshold for normal text. #767676 is the lightest neutral grey that passes on white, which is why it appears so often in design systems.
Does text colour on background count, or background on text?
The order does not matter. The ratio always puts the lighter colour's luminance on top, so black on white and white on black are both 21:1. Swap in this tool only changes which colour the sample renders as text.
Is WCAG contrast the same as APCA?
No. APCA is a newer perceptual model proposed for WCAG 3 that scores text differently depending on which colour is the foreground and on font size and weight. WCAG 2 contrast ratio is what current accessibility law and audits require.