DevToolCase
Sign in Sign in

Check color contrast (WCAG)

Check the WCAG 2 contrast ratio of a text color on its background: AA and AAA for normal text, large text and UI components.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

The contrast ratio

WCAG 2 compares the relative luminance of the two colors, how much light they give out, from 0 for black to 1 for white: the ratio is (lighter + 0.05) / (darker + 0.05). It goes from 1:1, the same color twice, to 21:1, black on white. Hue plays no part: red on green can have a fine hue difference and a poor ratio.

The ratio is rounded down, as WCAG requires: 4.499:1 does not reach 4.5:1. A translucent text color is blended onto the background first, and a translucent background onto white.

AA and AAA levels

ContentAAAAA
Normal text4.5:17:1
Large text: 24 px, or 18.66 px bold3:14.5:1
UI components and graphics: icons, field borders, focus rings, chart lines3:1—

Level AA is the usual target, required by most accessibility laws (the European Accessibility Act, the ADA in the United States, the RGAA in France). AAA is a stricter level, worth reaching for long texts.

What does not need contrast

  • Logos and brand names.
  • Disabled controls, which cannot be used anyway.
  • Purely decorative text and images, and text inside photos.
  • Placeholders do: a pale gray placeholder often fails 4.5:1.

Fixing a failing pair

Change the lightness, not the hue: darken the text or lighten the background until the ratio passes. The color converter shows the color in OKLCH, where lowering L darkens it evenly whatever its hue. Swapping the colors gives the same ratio: a pair that passes dark on light also passes light on dark.

A ratio is a minimum, not a guarantee: a thin font, a small size or a busy background image make text harder to read than the ratio says.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.