Why use Colour Contrast Checker
This WCAG color contrast checker calculates the contrast ratio between two hex colors and tests it against every WCAG 2 threshold at once. Normal text needs 4.5:1 for level AA and 7:1 for level AAA. Large text, meaning 18 point (24px) or 14 point bold (about 18.66px) and above, needs 3:1 for AA and 4.5:1 for AAA. Borders, icons and other interface components need 3:1. The default indigo #4f46e5 on white scores 6.29:1, which passes everything except AAA for normal text. A preview panel renders your sample text in the two colors at a size you choose, so you can judge a borderline pair by eye as well.
WCAG contrast requirements at a glance
| What you are checking | Level AA | Level AAA | WCAG success criterion |
|---|---|---|---|
| Normal text (under 18pt, or under 14pt bold) | 4.5:1 | 7:1 | 1.4.3 (AA), 1.4.6 (AAA) |
| Large text (18pt / 24px and up, or 14pt / 18.66px bold and up) | 3:1 | 4.5:1 | 1.4.3 (AA), 1.4.6 (AAA) |
| UI components: input borders, focus rings, icons that carry meaning | 3:1 | No AAA level | 1.4.11 |
| Graphics needed to understand content, such as chart lines | 3:1 | No AAA level | 1.4.11 |
| Disabled controls, decoration, logos | No requirement | No requirement | Exempt |
The tool reports the first three rows. The UI components result uses the same 3:1 cut-off as AA large text.
Contrast ratios of common color pairs
Every ratio and result below is the tool's output for the hex codes shown.
| Text | Background | Ratio | AA normal | AA large | AAA normal |
|---|---|---|---|---|---|
| Black #000000 | White #ffffff | 21.00:1 | Pass | Pass | Pass |
| Dark gray #333333 | White #ffffff | 12.63:1 | Pass | Pass | Pass |
| Gray #595959 | White #ffffff | 7.00:1 | Pass | Pass | Pass |
| Gray #767676 | White #ffffff | 4.54:1 | Pass | Pass | Fail |
| Gray #777777 | White #ffffff | 4.48:1 | Fail | Pass | Fail |
| Gray #808080 | White #ffffff | 3.95:1 | Fail | Pass | Fail |
| Gray #999999 | White #ffffff | 2.85:1 | Fail | Fail | Fail |
| Blue #0000ff | White #ffffff | 8.59:1 | Pass | Pass | Pass |
| Red #ff0000 | White #ffffff | 4.00:1 | Fail | Pass | Fail |
| Green #008000 | White #ffffff | 5.14:1 | Pass | Pass | Fail |
| Orange #ffa500 | White #ffffff | 1.97:1 | Fail | Fail | Fail |
| Yellow #ffff00 | White #ffffff | 1.07:1 | Fail | Fail | Fail |
| Black #000000 | Yellow #ffff00 | 19.56:1 | Pass | Pass | Pass |
| Red #ff0000 | Black #000000 | 5.25:1 | Pass | Pass | Fail |
| Light gray #e5e7eb | Near black #111827 | 14.33:1 | Pass | Pass | Pass |
How the contrast ratio is calculated
contrast ratio = (L1 + 0.05) / (L2 + 0.05)
L1 is the relative luminance of the lighter color and L2 of the darker one. To get relative luminance, divide each of the red, green and blue values by 255, then linearize it: values of 0.03928 or less are divided by 12.92, larger values become ((value + 0.055) / 1.055) raised to the power 2.4. Add the three results weighted 0.2126 for red, 0.7152 for green and 0.0722 for blue. White has a luminance of 1 and black 0, so black on white is 1.05 / 0.05 = 21, the highest ratio there is, and two identical colors give 1. Green carries by far the largest weight, which is why pure green or yellow text is so weak on white while pure blue is strong.
Worked contrast checks
Brand color as body text
Text colour #4f46e5, Background colour #ffffff
Contrast ratio 6.29:1. AA normal Pass, AA large Pass, AAA normal Fail, AAA large Pass, UI components Pass.
Placeholder gray
Text colour #9ca3af, Background colour #ffffff
Contrast ratio 2.54:1. Fails all five checks.
The slightly darker #6b7280 reaches 4.83:1 and passes AA for normal text.
White label on a red button
Text colour #ffffff, Background colour #dc2626
Contrast ratio 4.83:1. AA normal Pass, AAA normal Fail.
Just under the line
Text colour #777777, Background colour #ffffff
Contrast ratio 4.48:1. AA normal Fail, AA large Pass.
The tool compares the unrounded ratio with 4.5. WCAG does not allow rounding up, so 4.48 is a fail.
What the checker does not cover
The tool compares two solid, fully opaque colors. It does not accept an alpha value, so for semi-transparent text or overlays you need to work out the blended color first and enter that. For text on a gradient or a photo, sample the lightest and darkest parts of the background behind the text and check each against the text color; the worst result is the one that counts.
The Preview text size slider changes only the preview. It does not decide whether your text is large: read the AA large text row if your text is at least 24px, or at least 18.66px and bold, and the AA normal text row otherwise. The tool reports the ratio and the results but does not suggest a replacement color. To fix a failing pair, darken the darker color or lighten the lighter one in small steps and watch the ratio.
The ratio is the WCAG 2 measure that current standards and laws refer to. It ignores font weight and treats dark on light the same as light on dark, so some passing pairs on dark backgrounds are harder to read than the number suggests. Use the preview and treat 4.5:1 as a floor, not a target.
How to use it
- 1
Enter the Text colour as a hex code or pick it with the color swatch.
- 2
Enter the Background colour the text will sit on.
- 3
Read the Contrast ratio at the top, shown to two decimals against 1.
- 4
Check the WCAG results panel: AA normal text, AA large text, AAA normal text, AAA large text and UI components each show Pass or Fail with the ratio they need.
- 5
Type your own wording into Sample text and drag Preview text size between 12px and 40px to see the pair at the size you will use.