About this tool
Check the contrast between text and background colors using the WCAG 2 formula, see whether AA and AAA levels pass, and preview sample text. Helps web pages and designs meet accessibility readability guidelines.
Typical uses
- Check that button text is readable on a brand color
- Confirm body text colors meet accessibility standards
- Choose a palette with enough contrast
How to use
Enter text and background colors in HEX, RGB or HSL.
Check contrast to see the ratio, sample text and AA/AAA results.
Results use the WCAG 2 text contrast formula for two solid colors; they do not assess actual font size or other page accessibility issues.
How the ratio is calculated
The tool follows the WCAG 2 definitions. Each 0–255 channel is divided by 255; values up to 0.04045 are divided by 12.92, larger ones become ((value + 0.055) / 1.055)^2.4. The channels are weighted 0.2126 R + 0.7152 G + 0.0722 B to give the relative luminance L. The contrast ratio is (lighter L + 0.05) / (darker L + 0.05), from 1:1 to 21:1. Worked through for #2563EB: R 37 → 0.1451 → 0.0185 × 0.2126; G 99 → 0.3882 → 0.1248 × 0.7152; B 235 → 0.9216 → 0.8308 × 0.0722, so L = 0.1532. Against white that is 5.17:1, against black 4.06:1.
- Order does not matter: swap “Text color” and “Background color” and #2563EB with white still gives 5.17:1. Only the luminance difference counts, so dark-on-light and light-on-dark get the same number.
- Black on white is the maximum, 21.00:1; two identical colors give 1.00:1.
- Before May 2021 WCAG wrote the threshold as 0.03928; it is now 0.04045, and W3C notes the change has no practical effect. For 8-bit colors this is easy to confirm: none of the values 0–255 divided by 255 falls between the two (0 values), so old and new definitions give identical ratios.
- Inputs use the same notations as the color format converter (#RGB, #RRGGBB, rgb(r, g, b), hsl(h, s%, l%)) and transparency is not accepted. For semi-transparent text, work out the solid color it blends to on the real background and check that.
Which WCAG criterion each result line covers
“Check contrast” shows the ratio, four verdict lines, and a preview of “Sample text Aa 123” in your two colors:
| Line in the tool | WCAG success criterion | Applies to |
|---|---|---|
| AA (4.5:1) | WCAG 1.4.3 | Normal body text, level AA |
| AA large (3:1) | WCAG 1.4.3 | Large text, level AA |
| AAA (7:1) | WCAG 1.4.6 | Normal body text, level AAA |
| AAA large (4.5:1) | WCAG 1.4.6 | Large text, level AAA |
- In WCAG “large” means at least 18 point, or at least 14 point bold. W3C’s explanation puts 1pt at about 1.333px, so roughly 24px and 18.5px. For CJK fonts the “equivalent” size is meant, which W3C suggests reading as the minimum large-print size for those languages. The tool does not read your page’s font size, so you choose which line applies.
- Text in a logo or brand name, and text on an inactive (disabled) control, has no contrast requirement under 1.4.3.
- Non-text items such as button borders, input outlines and chart lines fall under WCAG 1.4.11, which asks for at least 3:1 against adjacent colors. The tool has no separate non-text line, but the ratio itself tells you whether 3:1 is reached.
- W3C warns that thin or unusual fonts can render fainter than their nominal color because of anti-aliasing; when a value is just over a threshold, check it on the real page.
The shown ratio is rounded, the verdict is not
The ratio is displayed with two decimals, but “Pass” or “Fail” compares the unrounded value with the threshold. That is what W3C asks for: computed values should not be rounded, and 4.499:1 does not meet 4.5:1. So a pair can show “4.50:1” and still fail:
| Text / background | Shown | Actual value | Note |
|---|---|---|---|
| #0078D7 / #FFFFFF | 4.50:1 | 4.4989 | AA (4.5:1): Fail, short by only 0.0011 |
| #0099FF / #FFFFFF | 3.00:1 | 2.9998 | AA large (3:1): Fail |
| #0050CA / #FFFFFF | 7.00:1 | 6.9993 | AAA (7:1): Fail |
| #767676 / #FFFFFF | 4.54:1 | 4.5422 | The lightest grey that passes AA on white |
| #777777 / #FFFFFF | 4.48:1 | 4.4781 | One step lighter fails AA |
When you see a borderline figure such as 4.50:1 or 3.00:1, trust the verdict lines below it, and darken the color one more step if you want a margin.
Common pairs and grey thresholds
Generated with the tool’s own calculation. The first row is the default, #111827 text on #FFFFFF:
| Text | Background | Ratio | AA (4.5:1) | AA large (3:1) | AAA (7:1) | AAA large (4.5:1) |
|---|---|---|---|---|---|---|
| #111827 | #FFFFFF | 17.74:1 | Pass | Pass | Pass | Pass |
| #FFFFFF | #2563EB | 5.17:1 | Pass | Pass | Fail | Pass |
| #FFFFFF | #3B82F6 | 3.68:1 | Fail | Pass | Fail | Fail |
| #FF0000 | #FFFFFF | 4.00:1 | Fail | Pass | Fail | Fail |
| #FF0000 | #000000 | 5.25:1 | Pass | Pass | Fail | Pass |
| #FFFFFF | #16A34A | 3.30:1 | Fail | Pass | Fail | Fail |
| #000000 | #16A34A | 6.37:1 | Pass | Pass | Fail | Pass |
| #9CA3AF | #FFFFFF | 2.54:1 | Fail | Fail | Fail | Fail |
| #E5E7EB | #FFFFFF | 1.24:1 | Fail | Fail | Fail | Fail |
Pure greys that just reach each threshold (the lightest on white, the darkest on black):
| Threshold | Lightest grey on white | Darkest grey on black |
|---|---|---|
| 3:1 | #949494 (3.03:1) | #5A5A5A (3.04:1) |
| 4.5:1 | #767676 (4.54:1) | #757575 (4.56:1) |
| 7:1 | #595959 (7.00:1) | #959595 (7.01:1) |
- Pure red #FF0000 is 4.00:1 on white, enough only for large-text AA, and 5.25:1 on black. A color that looks loud is not automatically high-contrast.
- #757575 reaches 4.61:1 on white and 4.56:1 on black, the best any grey can do against both at once; no grey reaches 7:1 on both.
- #9CA3AF, a common placeholder and disabled-text grey, gives only 2.54:1. If it carries information people must read, use at least #767676.
- The widely used #767676 is the floor for body text on white (4.54:1); #777777 already fails (4.48:1).
Sources
Frequently asked questions
What do AA and AAA mean?
They are WCAG readability levels. Normal text needs at least 4.5:1 for AA and 7:1 for AAA; large text has lower thresholds.
Does it consider font size?
Results are shown for normal and large text, but the tool does not read actual font sizes from your page.
Are gradients or image backgrounds supported?
Only the contrast between two solid colors is calculated.
Suggest an improvement to this tool
Missing an option, something awkward to use, or a wrong result? Let us know.