By Mudasir Ahsan (Founder) · Updated 10 November 2026
On this page
- How to use the color contrast checker
- The WCAG contrast ratio formula
- AA vs AAA contrast: what the WCAG levels mean
- Large text contrast: what counts as large
- Non-text contrast: buttons, icons and inputs
- Common color pairs and their ratios
- How to fix a failing pair
- Limits of the WCAG 2.x ratio and APCA
- Questions and answers
- Related calculators
How to use the color contrast checker
- Enter the text color as a hex code, for example
#333333. Three-digit shorthand such as#333works too, with or without the#. - Enter the background color the text sits on, for example
#FFFFFF. - Read the contrast ratio and the five pass/fail lines under it: AA and AAA for normal text, AA and AAA for large text, and the 3:1 rule for buttons, icons and form borders.
The order doesn't matter. Swapping text and background gives the same ratio, because the formula always puts the lighter color on top. If you only have RGB values, turn them into a code with the RGB to hex converter first; the hex to RGB converter goes the other way. To read a color out of a screenshot or a logo, the color picker from image gives you the hex.
The WCAG contrast ratio formula
This WCAG contrast checker uses the WCAG 2.1 definition of contrast ratio. The ratio is built from the relative luminance of each color, a number from 0 (black) to 1 (white) that models how bright the color looks to the eye:
Contrast ratio = (L1 + 0.05) ÷ (L2 + 0.05)
L1 is the relative luminance of the lighter color and L2 that of the darker one. The 0.05 stands for the light a screen reflects even when it shows black. It is the reason no pair can beat 21:1, and the reason the ratio is written as "something to one".
To get the relative luminance of a hex color:
- Split the code into red, green and blue (0 to 255) and divide each by 255.
- Linearize each channel, because sRGB values are gamma-encoded. If the value is 0.04045 or less, divide it by 12.92. Otherwise compute ((value + 0.055) ÷ 1.055)^2.4.
- Weight the channels by how sensitive our eyes are to them: L = 0.2126 × R + 0.7152 × G + 0.0722 × B.
Green carries most of the weight and blue very little. So white text on pure blue (#0000FF) scores a comfortable 8.59:1, while white on pure green (#00FF00) scores only 1.37:1.
Worked example: #777777 on white
77 in hex is 119, and 119 ÷ 255 = 0.4667. That is above 0.04045, so ((0.4667 + 0.055) ÷ 1.055)^2.4 = 0.1845. All three channels are the same, so L = 0.1845. White has L = 1. The ratio is (1 + 0.05) ÷ (0.1845 + 0.05) = 4.48:1, which misses the 4.5:1 minimum for normal text by a hair. The slightly darker #767676 gives 4.54:1 and passes. That is why such an odd gray turns up in so many design systems.
AA vs AAA contrast: what the WCAG levels mean
| Success criterion | Level | Normal text | Large text | Applies to |
|---|---|---|---|---|
| 1.4.3 Contrast (Minimum) | AA | 4.5:1 | 3:1 | Body copy, labels, links, placeholder text |
| 1.4.6 Contrast (Enhanced) | AAA | 7:1 | 4.5:1 | Sites aiming at the strictest level |
| 1.4.11 Non-text Contrast | AA | 3:1 against adjacent colors | Button and input borders, focus rings, icons, chart lines |
The full wording is in WCAG 2.1, Success Criterion 1.4.3. Both levels are measured with the same formula, and AAA is a higher bar.
A 4.5:1 contrast ratio is the number most people need. It is the AA requirement for normal text, and AA is the level that most accessibility laws, procurement rules and audits ask for. AAA (7:1) is usually kept for reading-heavy content or for sites with an older audience. W3C itself says AAA cannot be met for all content, so treat it as a goal and not as a gate.
Two kinds of text are exempt from 1.4.3: text that is purely decorative or part of an inactive control, and text inside a logo or brand name. A disabled button can be low-contrast. The text in a placeholder or a "hint" cannot.
Large text contrast: what counts as large
WCAG defines large text as at least 18 point, or 14 point bold. On the web a CSS point is 1⅓ pixels, so that is about 24px regular or 18.7px bold. Large text needs only 3:1 for AA and 4.5:1 for AAA, because bigger strokes are easier to read at lower contrast. White on pure red (#FF0000, 4.00:1) is fine for a big hero heading and fails for a paragraph.
The font size calculator shows which heading sizes in your type scale are over the 24px line. If your stylesheet uses rem, the px to rem converter translates the sizes.
Non-text contrast: buttons, icons and inputs
Since WCAG 2.1, two more things need 3:1 against the colors next to them. The first is any part of a control you must see in order to use it: a button's edge, an input's border, a checkbox, a focus ring. The second is any graphic needed to understand content, such as an icon without a label or a chart line.
Color contrast for buttons takes two checks. The label needs 4.5:1 against the fill. The fill needs 3:1 against the page background if its edge is what tells you it is a button. Light-gray input borders are the most common failure: #CCCCCC on white is 1.6:1.
Common color pairs and their ratios
| Text | Background | Ratio | AA normal | AAA normal |
|---|---|---|---|---|
| #000000 | #FFFFFF | 21.00:1 | Pass | Pass |
| #333333 | #FFFFFF | 12.63:1 | Pass | Pass |
| #595959 | #FFFFFF | 7.00:1 | Pass | Pass |
| #767676 | #FFFFFF | 4.54:1 | Pass | Fail |
| #777777 | #FFFFFF | 4.48:1 | Fail | Fail |
| #949494 | #FFFFFF | 3.03:1 | Fail (large text only) | Fail |
| #FFFFFF | #0000FF | 8.59:1 | Pass | Pass |
| #FFFFFF | #FF0000 | 4.00:1 | Fail (large text only) | Fail |
| #000000 | #FFFF00 | 19.56:1 | Pass | Pass |
| #FFFFFF | #00FF00 | 1.37:1 | Fail | Fail |
#595959 is the lightest gray that reaches 7:1 on white, #767676 the lightest that reaches 4.5:1, and #949494 the lightest that reaches 3:1. Keep those three as ceilings when you pick grays for a light theme.
How to fix a failing pair
Contrast depends on luminance and not on hue. The fix is almost always to make the dark color darker or the light color lighter, and changing the hue rarely helps. Accessible color contrast usually comes from a few small moves:
- Darken the text by a few hex steps and check again. Moving from
#777777to#767676was enough to cross 4.5:1 in the example above. - Avoid mid-tones for text. A saturated orange or a light blue on white rarely clears 3:1. Use it for large headings, or put it on a dark background.
- For text over a photo, check the darkest and the lightest points of the image, or add a solid or gradient overlay behind the words.
- Test dark mode separately. Light text on
#121212behaves differently from dark text on white. Pure white on pure black (21:1) can look harsh, so many dark themes use#E0E0E0text, which still gives 14.19:1.
A pass isn't the whole job, though. The ratio ignores weight, so a 12 px hairline font at 4.6:1 passes and is still hard to read. WCAG treats text as large from 24 px regular or about 18.7 px bold, and only that text gets the lower 3:1 bar. For body text at 14 px or 16 px, aim above 4.5:1 rather than right at it, because thin strokes look lighter on low-density screens than the formula assumes. The checker also can't see text over a photo or a gradient. There you have to test the worst spot yourself.
Limits of the WCAG 2.x ratio and APCA
The 2.x formula treats the two colors symmetrically and ignores font weight. It sometimes passes thin light text on a dark background that is hard to read, and it fails some dark-on-light pairs that look fine.
The W3C's WCAG 3 working draft explores a new method, the Accessible Perceptual Contrast Algorithm. APCA contrast is scored on a different scale and takes text size and weight into account. It is still a draft and is not a requirement anywhere. This checker reports the WCAG 2.1 ratio, which is what every current standard, audit tool and legal reference uses.
Two more limits apply. The ratio assumes opaque colors, so if your text or background has transparency, flatten it against what is behind it first. And the formula is defined for sRGB. If you work in a wide-gamut color space, read our guide to sRGB and Display P3 color profiles.
