Color Contrast Checker (WCAG AA and AAA)
Enter a text colour and a background colour as hex codes. You get the WCAG contrast ratio, a pass or fail for AA and AAA, and a preview of large and normal text.
Last reviewed
Contrast ratio
4.54:1
#767676 on #ffffff
Large text 24px
Normal text, 16px. The quick brown fox jumps over the lazy dog.
| WCAG test | Needs | Result |
|---|---|---|
| AA, normal text | 4.5:1 | Pass |
| AA, large text (18pt, or 14pt bold) | 3:1 | Pass |
| AAA, normal text | 7:1 | Fail |
| AAA, large text | 4.5:1 | Pass |
| AA, user interface components and graphics | 3:1 | Pass |
The ratio is not rounded when it is compared with a threshold, so 4.499:1 fails 4.5:1. It is shown cut off after two decimals so a failing number never looks like a pass.
What the checker does
Enter a text colour and a background colour as hex codes, or pick them with the colour pickers. The checker works out the WCAG contrast ratio and tells you which accessibility tests the pair passes, with a live preview of large and normal text in those colours. Nothing you enter leaves your browser.
The contrast ratio
The Web Content Accessibility Guidelines (WCAG 2.1) define it as (L1 + 0.05) ÷ (L2 + 0.05), where L1 is the relative luminance of the lighter colour and L2 of the darker. Relative luminance runs from 0 for black to 1 for white and is calculated from the red, green and blue values:
- Each channel is divided by 255 to give a number c between 0 and 1.
- If c is 0.04045 or less, the channel value is c ÷ 12.92. Otherwise it is ((c + 0.055) ÷ 1.055) raised to the power 2.4.
- Luminance L = 0.2126 × R + 0.7152 × G + 0.0722 × B.
Green carries the largest weight and blue the smallest. The ratio runs from 1:1 (the same colour) to 21:1 (black on white).
What the tests mean
| Test | WCAG criterion | Ratio needed |
|---|---|---|
| AA, normal text | 1.4.3 Contrast (Minimum) | 4.5:1 |
| AA, large text | 1.4.3 Contrast (Minimum) | 3:1 |
| AAA, normal text | 1.4.6 Contrast (Enhanced) | 7:1 |
| AAA, large text | 1.4.6 Contrast (Enhanced) | 4.5:1 |
| AA, interface components and graphics | 1.4.11 Non-text Contrast | 3:1 |
Large text is at least 18 point, or 14 point bold. WCAG gives 1pt as 1.333px, so 18pt is 24px and 14pt is about 18.67px. Level AAA is the stricter level.
Text that is part of a logo or brand name, and text in an inactive control, have no contrast requirement under the guidelines.
No rounding
WCAG says the computed values should not be rounded: 4.499:1 does not meet 4.5:1. The checker compares the exact ratio with each threshold, and shows the ratio cut off at two decimals, never rounded up, so a failing pair cannot look like a pass.
Worked examples
| Text colour | Background | Ratio | AA normal | AA large | AAA normal |
|---|---|---|---|---|---|
| #000000 | #ffffff | 21.00 | Pass | Pass | Pass |
| #595959 | #ffffff | 7.00 | Pass | Pass | Pass |
| #6c757d | #ffffff | 4.68 | Pass | Pass | Fail |
| #767676 | #ffffff | 4.54 | Pass | Pass | Fail |
| #777777 | #ffffff | 4.47 | Fail | Pass | Fail |
| #949494 | #ffffff | 3.03 | Fail | Pass | Fail |
| #ff0000 | #ffffff | 3.99 | Fail | Pass | Fail |
| #0000ff | #ffffff | 8.59 | Pass | Pass | Pass |
| #00ff00 | #000000 | 15.30 | Pass | Pass | Pass |
- Black on white: black has luminance 0 and white has 1, so the ratio is (1 + 0.05) ÷ (0 + 0.05) = 1.05 ÷ 0.05 = 21.
- #767676 on white: each channel is 118 ÷ 255 = 0.4627, which becomes ((0.4627 + 0.055) ÷ 1.055)^2.4 = 0.1812. The ratio is 1.05 ÷ (0.1812 + 0.05) = 4.54. Of the greys with equal red, green and blue values, it is the lightest that passes AA for normal text on white.
- One step lighter, #777777: 0.1845 gives 1.05 ÷ 0.2345 = 4.47, which fails.
- Pure red on white: red alone has luminance 0.2126, so 1.05 ÷ 0.2626 = 3.998, shown as 3.99. It fails for normal text because 3.998 is below 4.5, though it passes for large text.
Common mistakes
- Eyeballing it. Colours that look fine to one reader can fail the test.
- Rounding up. A ratio of 4.499 fails.
- Forgetting the size. Large text needs less contrast, and only text of 18pt (24px) or 14pt bold counts as large.
- Checking only the default state. Hover, focus, disabled and placeholder text are checked separately.
- Testing over images or gradients. The checker takes one flat colour for each side, so test the worst spot of a gradient or image.
For converting CSS sizes, see the px to rem converter. For colour and length conversions in general, use the unit converter.
How it is calculated
Each hex colour is split into red, green and blue, turned into a linear channel value, and combined with the weights 0.2126, 0.7152 and 0.0722. The ratio uses 50-digit decimal arithmetic, so that a pair on the edge of a threshold is judged on its exact value, and it is cut off at two decimals for display.
Frequently asked questions
What contrast ratio do I need for text?
WCAG 2.1 level AA needs at least 4.5:1 for normal text and 3:1 for large text. Level AAA needs 7:1 for normal text and 4.5:1 for large text. User interface components and graphics need 3:1 under 1.4.11.
What counts as large text?
At least 18 point, or 14 point bold. WCAG gives 1pt as 1.333px, so that is 24px, or about 18.67px in bold. Anything smaller counts as normal text.
How is the contrast ratio calculated?
It is (L1 + 0.05) ÷ (L2 + 0.05), where L1 and L2 are the relative luminances of the lighter and darker colours, from 0 for black to 1 for white. Luminance weights red, green and blue by 0.2126, 0.7152 and 0.0722 after a gamma correction.
Is 4.499:1 close enough to pass?
No. WCAG says the computed values should not be rounded, so 4.499:1 does not meet 4.5:1. The checker compares the exact ratio and shows it cut off after two decimals so it never looks like a pass when it is not.
What is the lightest grey that passes on white?
#767676 has a ratio of 4.54:1 on white and passes AA for normal text. #777777 is 4.47:1 and fails. For AAA, #595959 gives 7.00:1.
Does the checker store my colours?
No. The calculation runs in your browser, and the colours are only written to the page address if you copy the link, so you can share a result.
Related calculators
- PX to REM ConverterEnter a size in pixels or rem and your root font size.
- Unit ConverterPick what you are converting, enter a value, choose the two units, and read the answer.
- Hash GeneratorType or paste text and see its MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes at once, as hex or base64.
- JWT DecoderPaste a JSON Web Token.
- UUID GeneratorChoose version 4 (random) or version 7 (time-ordered) and how many to make.
- Password GeneratorChoose a length and the kinds of character to use, then press Generate.