Color Contrast Checker

Enter text and background hex colors to get the exact WCAG 2 contrast ratio and pass or fail for AA and AAA, normal and large text, with a live preview.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Color Contrast Checker?

The Color Contrast Checker computes the WCAG 2 contrast ratio between a text color and a background color and tells you whether the pair passes AA and AAA for normal text and for large text. Type hex values (#rgb or #rrggbb) or use the color pickers, and the ratio, the four results and a sample block of text update immediately.

Pass or fail is decided on the exact ratio. The number shown is cut to two decimals rather than rounded up, so #006ffb on white reads 4.49:1 and fails AA for normal text even though it is only 0.0001 short. Many quick checkers round that to 4.5 and pass it.

Swap Colors flips foreground and background, Copy puts both colors, the ratio and the results on your clipboard, and the reset button returns to black on white. The check runs in your browser. It handles solid colors only: no transparency, gradients or text over images.

  • Exact WCAG 2.x contrast ratio from the official luminance formula
  • AA and AAA results for normal and large text
  • No rounding up: 4.499:1 is reported as a fail
  • Accepts #rgb and #rrggbb, with a color swatch for each color
  • Live preview at body, large and large bold sizes
  • Runs in your browser
Read the guide: WCAG Color Contrast: How the Ratio Works and How to Pass AA

Updated

How to use the Color Contrast Checker

  1. Enter the text color in Foreground Color (Text) and the background in Background Color, as hex or with the color swatch.
  2. Read the Contrast Ratio and the Normal Text and Large Text badges: AAA, AA or Fail.
  3. Look at the Live Preview to see the pair at 16px, 24px and 18.66px bold.
  4. Use Swap Colors to test the reversed pair for dark mode, and Copy to paste the result into a ticket or design review.

Worked examples

The lightest grey that passes on white

Input

Foreground #767676, background #ffffff

Output

4.54:1, Normal Text AA, Large Text AAA

One step lighter, #777777, gives 4.47:1 and fails AA for normal text. #767676 is the well-known limit for grey body text on white.

A near miss that rounding would hide

Input

Foreground #006ffb, background #ffffff

Output

4.49:1, Normal Text Fail, Large Text AA

The exact ratio is 4.4999. Rounded to one decimal it would look like 4.5 and pass, but WCAG compares the unrounded value, so it fails for body text.

White text on a common blue button

Input

Foreground #ffffff, background #3b82f6

Output

3.67:1, Normal Text Fail, Large Text AA

Fine for a 24px heading, not for a 16px button label. Darkening the blue to #2563eb raises the ratio to 5.16:1 and passes AA for all text sizes.

Background and insight

The formula comes from WCAG 2.0 (2008) and is unchanged in WCAG 2.1 and 2.2. Each sRGB channel is scaled to 0 to 1 and linearised: values at or below 0.04045 are divided by 12.92, the rest go through ((c + 0.055) / 1.055) raised to 2.4. Relative luminance is then 0.2126 R + 0.7152 G + 0.0722 B, which is why green contributes most to perceived brightness and blue barely matters. The contrast ratio is (L1 + 0.05) / (L2 + 0.05) with L1 the lighter color, giving a range from 1:1 to 21:1.

Success Criterion 1.4.3 (AA) asks for 4.5:1 for normal text and 3:1 for large text. 1.4.6 (AAA) raises that to 7:1 and 4.5:1. Large means at least 18 point or 14 point bold. CSS has 96 pixels per inch and 72 points per inch, so that is 24px regular or about 18.66px bold. A common mistake is reading "18" as 18px: a 20px semibold subheading is still normal text under WCAG.

WCAG explicitly says not to round: 4.499:1 does not meet 4.5:1. The successor algorithm being discussed for WCAG 3, APCA, weighs font size and polarity differently and often disagrees with these results, especially for dark mode. For legal and procurement purposes today (ADA cases in the US, EN 301 549 in the EU), WCAG 2 ratios are what auditors check.

Common use cases

  • Design reviews

    Check each text and background pair in a palette before it reaches code, including placeholder and disabled text.

  • Accessibility audits

    Verify findings from automated scanners and get an exact ratio to put in the audit report.

  • Dark mode palettes

    Swap colors to test light text on dark surfaces, where low contrast mistakes are common.

  • Brand color decisions

    Find out whether a brand color can carry white text or needs a darker shade for buttons and links.

Tips and limitations

  • Large text is 24px regular or 18.66px bold (700 or heavier). A 20px semibold heading still needs 4.5:1.
  • WCAG 1.4.11 asks for 3:1 for UI components and graphics, such as input borders, focus rings and chart lines. Use the large text threshold as the check for those.
  • Semi-transparent text has to be checked using the color it actually renders as. Blend it with the background first, for example with the Color Picker, then test the result.
  • Text over gradients or photos needs checking against the lightest and darkest areas behind it, not the average.

Sources and further reading

  1. Web Content Accessibility Guidelines (WCAG) 2.2, W3C. Success criteria 1.4.3 and 1.4.6, and the relative luminance and contrast ratio definitions
  2. Understanding Success Criterion 1.4.3: Contrast (Minimum), W3C Web Accessibility Initiative. Why 4.5:1 and 3:1, what counts as large text, and why ratios are not rounded
  3. Understanding Success Criterion 1.4.6: Contrast (Enhanced), W3C Web Accessibility Initiative. The 7:1 AAA level
  4. W3C Accessibility Guidelines (WCAG) 3.0, W3C. The working draft that may replace the WCAG 2 contrast method
  5. Guidance on Web Accessibility and the ADA, US Department of Justice. How the ADA applies to websites in the US

Frequently asked questions

What contrast ratio do I need to pass WCAG AA?

WCAG AA requires at least 4.5:1 for normal text and 3:1 for large text, which is 24px regular or about 18.66px bold. AAA raises those to 7:1 and 4.5:1. Non-text elements such as icons, input borders and focus indicators need 3:1 under criterion 1.4.11.

How is the WCAG contrast ratio calculated?

Each color is converted to relative luminance: channels are linearised from sRGB and weighted 0.2126 for red, 0.7152 for green and 0.0722 for blue. The ratio is (lighter + 0.05) divided by (darker + 0.05). Black on white gives 21:1 and any color on itself gives 1:1.

Why does this checker say 4.49 when another tool says 4.5?

This checker truncates the display to two decimals and never rounds a failing ratio up. Some tools round, so a pair at 4.4999:1 appears as 4.5:1 and passes. WCAG says thresholds are exact, so 4.4999 fails AA for normal text.

Is 18px bold text considered large text under WCAG?

No. Large text is at least 14 point bold, which is about 18.66 CSS pixels, or 18 point regular, which is 24px. 18px bold falls just short, so it needs 4.5:1 for AA. Many teams get this wrong by reading the point sizes as pixels.

Can I check text with opacity or rgba colors?

Not directly. The checker accepts solid hex colors. Work out the color the text actually renders as by blending it with its background, then enter that hex value. Browser developer tools show the computed blended color when you inspect contrast.

What about APCA and WCAG 3?

APCA is a newer contrast method proposed for WCAG 3, which is still a draft. It accounts for font weight and treats light-on-dark differently from dark-on-light. Until WCAG 3 is final, legal and procurement requirements still reference the WCAG 2 ratio that this tool computes.

Is there an in-depth guide to the Color Contrast Checker?

Yes. “WCAG Color Contrast: How the Ratio Works and How to Pass AA” covers the background, how it works, common pitfalls and worked examples. Read the full guide.