Saved

Press the star next to a tool's name to save it.

All my tools

Color Contrast Checker

Enter a text color and a background color, and this color contrast checker works out the WCAG contrast ratio and shows whether the pair passes AA and AAA.

Use hex codes such as #336699, or rgb(51, 102, 153).

Your colors stay in your browser. Nothing is uploaded.

Contrast ratio

–

Enter two colors and press Check contrast.

A color contrast checker tells you whether text will be easy to read against its background. Enter a text color and a background color, and this color contrast checker works out the contrast ratio defined by the Web Content Accessibility Guidelines, or WCAG. You'll see at once whether the pair passes the AA and AAA levels for normal and large text, along with a live sample of how it looks. If the combination falls short, the tool suggests the closest text color that passes, so you can fix a design without starting again.

How the color contrast checker works

WCAG compares the relative luminance of two colors, which is their relative brightness on a scale from 0 for the darkest black to 1 for the lightest white. The tool calculates the luminance of each color, and then applies this formula:

Contrast ratio = (lighter luminance + 0.05) ÷ (darker luminance + 0.05)

The result runs from 1:1, for two identical colors, to 21:1, for black on white. The displayed value is cut off at two decimal places and never rounded up, so that a pair that's just below a limit can't appear to pass.

WCAG contrast levels

LevelNormal textLarge text
AA (minimum)4.5:13:1
AAA (enhanced)7:14.5:1

How to use the checker

  1. Enter your text color.
  2. Enter your background color.
  3. Press Check contrast.
  4. Look at the sample and the results.
  5. Use the suggested color if the pair doesn't pass.

A worked example

Medium gray text, #767676, on a white background gives a ratio of 4.54:1. That's just enough to pass AA for normal text, although it isn't enough for AAA. Make the gray slightly lighter, at #777777, and the ratio falls to 4.47:1, which fails AA. Two colors that look nearly identical to the eye can land on opposite sides of the line, and that's exactly why it's useful to measure them. In that second case, the tool suggests a slightly darker shade that passes.

Why contrast matters

The goal of this rule is that text can be seen by more people. According to the W3C, it's intended to provide enough contrast between text and its background so that people with moderately low vision or impaired contrast perception can read it without assistive technology. Many visual impairments can substantially affect contrast sensitivity, and they require more light-dark contrast regardless of the color. Good contrast also helps everyone else, such as someone reading a phone outdoors in bright sunlight.

What counts as large text?

WCAG treats large-scale text differently because bigger letters are easier to read. The W3C's guidance defines it by point size and weight, and you should check the current definition for your project. If you're unsure whether your text qualifies, use the normal text standard, since it's the stricter one.

What's exempt?

The minimum contrast requirement doesn't apply to everything. The W3C lists a few exceptions. Text or images of text that are part of an inactive interface component, that are pure decoration, that aren't visible to anyone, or that are part of a picture with significant other visual content have no contrast requirement. Text that's part of a logo or brand name has no contrast requirement either.

Tips for accessible color

  • Check every state. Links, hover effects and disabled buttons all have their own colors.
  • Don't rely on color alone. Pair it with text or an icon so that the meaning is clear.
  • Be careful with text over images. Add a solid or semi-transparent layer behind it.
  • Test dark mode separately. A pair that works on white may fail on a dark background.
  • Avoid pure red on green and similar pairs that many people find hard to separate.

Fixing a color that fails

When a pair doesn't reach 4.5:1, you can usually adjust the text color only and leave your background alone. The tool moves your text color toward black on a light background, or toward white on a dark background, in small steps until it passes. This keeps the color as close as possible to your original choice. You may then want to round the result to a shade that's already in your design system.

Colors that often cause problems

Some popular design choices are more likely to fail than others. Light gray text on white is one of the most common issues, particularly for captions, placeholders and small notes. Orange and yellow buttons with white labels often fall short too, as do pastel backgrounds with colored text. When you're building a palette, it helps to check each text color against every background that it could appear on, and to record the pairs that pass so that your team can reuse them.

Common mistakes

  • Judging contrast by eye. Small differences can decide a pass or fail.
  • Testing only the main text. Placeholders and captions matter too.
  • Rounding up. A ratio of 4.49:1 doesn't meet 4.5:1.

Find a shade with the color picker, tidy your page with the HTML formatter, and shrink your stylesheets with the CSS and JavaScript minifier.

What next

Use this often? Add Color Contra to your Home screen.

Frequently asked questions

How does the color contrast checker work?

It calculates the relative luminance of both colors and applies the WCAG contrast ratio formula.

What contrast ratio do I need?

WCAG AA needs at least 4.5:1 for normal text and 3:1 for large text.

What is AAA contrast?

It's the enhanced level, which needs 7:1 for normal text and 4.5:1 for large text.

Do logos need to pass?

No. Text that's part of a logo or brand name has no contrast requirement.

What color formats can I use?

Hex codes such as #336699 or #369, and rgb(51, 102, 153).

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools