Toolnido

WCAG Color Contrast Checker: Ratio and the Closest Color That Passes

Check the WCAG contrast ratio of a text and background color for AA and AAA, then get the closest lighter or darker color that passes. Runs in your browser.

The colours are checked in this browser. Nothing is uploaded or sent to a server.

Colours

Use 3 or 6 hex digits, for example #333 or #1a73e8.

When to use this

  • You are picking text or button colors and need to know if they meet WCAG AA or AAA.
  • A color fails and you want the nearest shade that passes instead of guessing.
  • You want a link to a color pair to send to a designer or developer.

How to use

  1. Type the text color and the background color as hex codes, such as #333 or #1a73e8.
  2. Press Check contrast to see the ratio and each WCAG check.
  3. If a check fails, read the closest passing text color or background color in the suggestions.
  4. Copy the result or a link to the pair.

Examples

Understanding the result

Each color is turned into a relative luminance between 0 (black) and 1 (white). The contrast ratio is (lighter + 0.05) divided by (darker + 0.05). WCAG 2.x asks for at least 4.5 : 1 for normal text and 3 : 1 for large text and icons at level AA, and 7 : 1 and 4.5 : 1 at level AAA. The suggestion keeps the hue and saturation and moves only the lightness, by the smallest step that reaches the goal.

Limitations

FAQ

What contrast ratio do I need for WCAG AA?

At least 4.5 : 1 for normal text and 3 : 1 for large text. Icons and input borders also need 3 : 1.

What is the difference between AA and AAA?

AAA is stricter: 7 : 1 for normal text and 4.5 : 1 for large text.

How is the closest passing color chosen?

The tool keeps the hue and saturation, moves the lightness lighter or darker in small steps and picks the smaller change that reaches the goal.

Can a near miss show as a pass?

The value is rounded to two decimals, but a ratio just under a pass mark is rounded down, so 4.499 shows as 4.49 and fails, as it should.

Are my colors sent anywhere?

No. Everything is calculated in your browser. A share link stores the two colors after the # sign, which is not sent to a server.

Related tools