ToolNimba

๐ŸŒ— Contrast Checker for WCAG Color Accessibility

Shihab Mia By Shihab Mia ยท Updated 2026-07-03

The quick brown fox jumps over the lazy dog. 0123456789.

Large heading sample text

21.00:1 contrast ratio

Normal text

  • AA (4.5:1)
  • AAA (7:1)

Large text (18pt+ or 14pt+ bold)

  • AA (3:1)
  • AAA (4.5:1)

This contrast checker measures how readable text is against its background using the official WCAG formula. Enter a foreground (text) color and a background color as hex values or pick them visually, and the contrast checker instantly returns the contrast ratio along with pass or fail results for WCAG AA and AAA at normal text, large text, and non-text UI sizes. A live preview shows the actual color pairing so you can judge readability at a glance before you commit it to a design.

What is the Color Contrast Checker?

A contrast checker answers one practical question: can people actually read this text? Color contrast is the difference in perceived brightness between text and its background. The Web Content Accessibility Guidelines (WCAG) express it as a ratio that ranges from 1:1 (identical colors, invisible text) to 21:1 (pure black on pure white). The higher the ratio, the easier the text is to read, especially for people with low vision or color vision deficiencies. Good contrast also helps everyone reading in bright sunlight, on a cheap screen, or while glancing quickly at a phone.

The ratio a contrast checker reports is not a simple comparison of hex values. WCAG first converts each color to its relative luminance, a number that models how bright the human eye perceives it. Each red, green, and blue channel is scaled to a 0 to 1 range, linearized with a gamma curve, and then weighted, with green counting most and blue least because the eye is most sensitive to green. The contrast ratio is then (L1 + 0.05) divided by (L2 + 0.05), where L1 is the lighter color and L2 the darker one. The 0.05 term accounts for ambient screen glare, which is why even black on white tops out at 21:1 rather than infinity.

WCAG sets two thresholds that this contrast checker evaluates for you. Level AA, the common legal and practical baseline, requires 4.5:1 for normal text and 3:1 for large text. Level AAA is stricter at 7:1 for normal and 4.5:1 for large text. Large text is defined as 18pt (about 24px) and larger, or 14pt (about 18.66px) bold and larger, since bigger glyphs stay legible at lower contrast. A separate rule, WCAG 1.4.11, requires 3:1 for meaningful non-text elements such as icons, input borders, and focus rings. Logos and purely decorative text are exempt from all of these.

A common point of confusion that a contrast checker clears up is that contrast is symmetric: swapping the text and background colors gives the exact same ratio, because the formula always puts the lighter luminance on top. So the tool tells you whether a pair is readable, not which color should be the text. That design choice is yours, and the live preview helps you decide which arrangement looks right. This matters because contrast is one of the most cited issues in real accessibility audits, and automated scanners like Lighthouse and axe flag it aggressively.

Why accessibility standards insist on this rather than leaving it to taste: contrast failures disproportionately affect an aging audience. Roughly one in twelve men has some form of color vision deficiency, and low-contrast gray-on-gray interfaces are effectively unreadable for many older users whose lenses transmit less light. A good contrast checker turns a subjective argument about whether text looks fine into a single measured number that a whole team, and any legal reviewer, can agree on. Using the contrast checker early in the design process is far cheaper than retrofitting an entire color system after an audit fails.

Finally, remember that passing a contrast checker is necessary but not sufficient for readable text. WCAG contrast ignores font weight, letter spacing, anti-aliasing, and text over busy photographs, all of which affect real legibility. Treat the ratio as a hard floor, not a ceiling: pairs that clear AA comfortably (say 7:1 or better) give you headroom for hover states, translucency, and imperfect displays. The contrast checker gives you the objective measurement, and your judgment supplies the rest.

When to use it

  • Checking whether your website body text meets WCAG AA before launch or an accessibility audit.
  • Choosing a button text color that stays legible against a brand background color.
  • Validating a design system palette so every text-on-surface pairing passes a known threshold.
  • Fixing a specific contrast failure flagged by Lighthouse, axe, or a manual accessibility review.
  • Verifying that icons, input borders, and focus rings meet the 3:1 non-text UI requirement.
  • Comparing candidate link and hover colors so states stay readable, not just the default text.

How to use the Color Contrast Checker

  1. Enter the foreground (text) color as a hex value, or use the color picker.
  2. Enter the background color the same way.
  3. Read the contrast ratio shown at the top of the results.
  4. Check the AA and AAA pass or fail badges for normal and large text.
  5. If a pairing fails, darken the text or lighten the background and recheck until it passes.

Formula & method

For each channel c (0 to 1): if c ≤ 0.03928, clin = c / 12.92, else clin = ((c + 0.055) / 1.055)2.4.   L = 0.2126·Rlin + 0.7152·Glin + 0.0722·Blin.   ratio = (Llighter + 0.05) ÷ (Ldarker + 0.05).
WCAG Contrast Ratio Scale1:1 fail4.5:1 AA7:1 AAA21:1 maxratio = (Llight + 0.05) / (Ldark + 0.05)21:1 pass4.5:1 AA2.3:1 fail

Worked examples

Black text (#000000) on white (#FFFFFF), the maximum possible contrast.

  1. White luminance L = 1.0 (all channels are 255, fully linearized to 1).
  2. Black luminance L = 0.0 (all channels are 0).
  3. ratio = (1.0 + 0.05) / (0.0 + 0.05) = 1.05 / 0.05 = 21

Result: 21:1, passes AA and AAA at every text size.

Medium gray text (#767676) on white (#FFFFFF), a classic borderline case.

  1. Channel value 0x76 = 118, so c = 118 / 255 = 0.4627.
  2. Linearized: ((0.4627 + 0.055) / 1.055)^2.4 = 0.1812, so gray L = 0.1812.
  3. ratio = (1.0 + 0.05) / (0.1812 + 0.05) = 1.05 / 0.2312 = 4.54

Result: 4.54:1, just passes AA for normal text (4.5) but fails AAA (7).

White text (#FFFFFF) on brand blue (#2563EB), a typical button pairing.

  1. Blue channels: R = 37/255 = 0.1451, G = 99/255 = 0.3882, B = 235/255 = 0.9216.
  2. Linearize each: R = 0.0185, G = 0.1237, B = 0.8308.
  3. Blue L = 0.2126*0.0185 + 0.7152*0.1237 + 0.0722*0.8308 = 0.1524.
  4. ratio = (1.0 + 0.05) / (0.1524 + 0.05) = 1.05 / 0.2024 = 5.19

Result: About 5.17:1, passes AA for normal and large text but fails AAA for normal text.

WCAG contrast ratio requirements by level and text size

Conformance levelNormal textLarge text
AA (minimum)4.5:13:1
AAA (enhanced)7:14.5:1
Non-text UI (AA)3:13:1

What counts as "large text" under WCAG

StyleMinimum size
Regular weight18pt (about 24px)
Bold weight14pt (about 18.66px)

Common gray-on-white pairings and where they pass

Text color on whiteRatioAA normalAAA normal
#000000 (black)21.0:1PassPass
#5959597.0:1PassPass
#7676764.54:1PassFail
#9494943.0:1FailFail
#AAAAAA2.32:1FailFail

Common mistakes to avoid

  • Comparing hex numbers instead of luminance. Contrast is not the numeric gap between hex codes. Two colors can have similar hex values but very different perceived brightness. Always use the luminance-based ratio, which is what this contrast checker computes.
  • Assuming all text needs 4.5:1. Large text only needs 3:1 for AA. Headings and big labels can use lower contrast than body copy, which gives more design freedom without failing the guideline.
  • Forgetting hover, focus, and disabled states. A pairing that passes at rest can fail when a link turns a lighter shade on hover or when placeholder text is dimmed. Check every state with the contrast checker, not just the default one.
  • Ignoring contrast on icons and form borders. WCAG 1.4.11 requires 3:1 for meaningful non-text elements like icons, input outlines, and focus rings, not just text. A pretty but faint border can still be a failure.
  • Testing text over an image with a single color. Photos and gradients have many luminance values. A contrast checker only measures two flat colors, so add a solid overlay or text shadow and test against the lightest patch behind the text.
  • Treating a bare pass as safe. A ratio of exactly 4.5:1 has no margin for cheap screens, sunlight, or anti-aliasing. Aim comfortably above the threshold, ideally 7:1 for body text, so real-world conditions do not push it into failure.

Glossary

Contrast ratio
A number from 1:1 to 21:1 describing the luminance difference between two colors. Higher means more readable.
Relative luminance
A 0 to 1 value modeling how bright the human eye perceives a color, after gamma correction and channel weighting.
WCAG
Web Content Accessibility Guidelines, the international standard for making web content usable by people with disabilities.
Level AA
The mid tier of WCAG conformance, widely used as the legal and practical baseline for contrast.
Level AAA
The enhanced tier of WCAG conformance, requiring 7:1 for normal text and 4.5:1 for large text.
Large text
Text at 18pt and up, or 14pt and up if bold. It qualifies for the lower 3:1 (AA) contrast threshold.
Gamma correction
The nonlinear curve applied to each color channel so stored values match how displays emit and eyes perceive light.
Non-text contrast
WCAG 1.4.11, which requires a 3:1 ratio for meaningful graphics and UI parts like icons, borders, and focus indicators.

Frequently asked questions

What is a good color contrast ratio?

A ratio of 4.5:1 or higher passes WCAG AA for normal text, and 7:1 or higher passes the stricter AAA level. Large text needs only 3:1 for AA. Aim for at least 4.5:1 on body copy, and use this contrast checker to confirm it.

How is WCAG contrast ratio calculated?

Each color is converted to relative luminance: channels are scaled to 0 to 1, gamma corrected, and weighted (0.2126 red, 0.7152 green, 0.0722 blue). The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05).

What is the difference between WCAG AA and AAA?

AA is the common baseline: 4.5:1 for normal text and 3:1 for large text. AAA is the enhanced level: 7:1 for normal and 4.5:1 for large text. Most sites target AA, while AAA suits high-accessibility contexts.

What counts as large text for contrast?

Large text is 18pt (about 24px) or larger at normal weight, or 14pt (about 18.66px) or larger when bold. Large text qualifies for the lower 3:1 AA threshold instead of 4.5:1.

Does contrast apply to icons and buttons?

Yes. WCAG 1.4.11 requires a 3:1 ratio for meaningful non-text elements such as icons, input borders, and focus indicators, so check those with the contrast checker alongside your text colors.

Why does black on white give 21:1?

Pure white has a relative luminance of 1.0 and pure black 0.0. Plugging these into the formula gives (1.0 + 0.05) / (0.0 + 0.05) = 21, the maximum possible contrast ratio.

Does swapping text and background color change the ratio?

No. The contrast checker always divides by the lighter luminance, so white on blue and blue on white give the identical ratio. The tool tells you if a pair is readable, not which color should be the text.

Is a color contrast checker enough to pass an accessibility audit?

It covers the contrast success criteria, but not everything. WCAG contrast ignores font weight, spacing, and text over images, so also review keyboard access, alt text, and structure. Use the contrast checker as one required step, not the whole audit.

What contrast ratio do I need for placeholder or disabled text?

Placeholder text must still meet 4.5:1 (or 3:1 if large) because it conveys information. Genuinely disabled controls are exempt from the contrast minimum, but keep them distinguishable so users can tell what is off.

How do I fix text that fails the contrast checker?

Darken the text or lighten the background, then recheck. Small luminance shifts often move a borderline pair above 4.5:1. If the brand color is fixed, adjust the other color or increase the text size to qualify for the 3:1 large-text rule.

Sources