Free developer tool

Check two hex colors against the WCAG contrast thresholds

For designers and front-end developers who need to know whether a text color is readable on a given background. Both colors stay in your browser; nothing is sent anywhere.

Ratio to two decimal placesAA and AAA text thresholdsLive preview and swap button
Color Contrast Checker

Enter a text color and a background color as hex. The preview, the contrast ratio and the WCAG verdicts update as you type.

Runs on your device
Readable text matters.Preview at large and normal sizes
18.06:1
Contrast ratio1:1 identical, 21:1 black on white
Pass
Normal text AAneeds 4.5:1
Pass
Large text AAneeds 3:1
Pass
Normal text AAAneeds 7:1

What the Color Contrast Checker does

The Color Contrast Checker takes a text color and a background color, both as hex values, and calculates the contrast ratio defined in WCAG 2.2. The result is shown as a figure such as 4.54:1 next to three verdicts: Normal text AA (needs 4.5:1), Large text AA (needs 3:1) and Normal text AAA (needs 7:1).

Each color has a native color picker and a text field that accepts three- or six-digit hex, with or without the leading #. A swap button exchanges the two colors, which is useful for testing the dark-mode version of the same pair. A preview block renders sample text in your chosen colors so you can judge the result by eye as well as by number.

It suits quick checks while choosing a palette, reviewing a design handoff or answering an accessibility audit finding. For a full audit you still need to test real rendered pages, because font size, weight and anti-aliasing affect legibility in ways a ratio cannot capture.

How to use it

Enter the text color

Type a hex value such as #17132A or #333 into the Text color field, or pick one with the color swatch. The default pair is a near-black on white, which scores 18.06:1.

Enter the background color

Set the color that will sit behind the text in the same way. Invalid input replaces the results with a message asking for a valid 3- or 6-digit hex color.

Read the ratio and the three verdicts

The ratio updates as you type. Normal text AA, Large text AA and Normal text AAA each show Pass or Fail against their fixed thresholds.

How the contrast ratio is calculated

The tool follows the formula in WCAG 2.2. Each hex channel is divided by 255 and linearized with the sRGB transfer curve: values at or below 0.04045 are divided by 12.92, higher values use ((channel + 0.055) / 1.055) raised to the power 2.4. The linear channels are weighted 0.2126 red, 0.7152 green and 0.0722 blue to give relative luminance. The ratio is (lighter luminance + 0.05) divided by (darker luminance + 0.05).

The result ranges from 1:1 for identical colors to 21:1 for pure black on pure white. Because the darker color is always the divisor, swapping text and background does not change the ratio; it only changes how the preview looks.

The ratio is displayed rounded to two decimal places, but the Pass or Fail comparison uses the unrounded value. A pair that is a hair under a threshold fails even if the display rounds up to it.

What the three verdicts mean

WCAG success criterion 1.4.3 Contrast (Minimum), level AA, requires at least 4.5:1 for ordinary text and 3:1 for large text. Success criterion 1.4.6 Contrast (Enhanced), level AAA, raises those to 7:1 and 4.5:1. WCAG defines large text as at least 18 point, or 14 point when bold, which is roughly 24 CSS pixels, or 18.66 pixels for bold.

Incidental text, pure decoration, logotypes and text inside inactive controls are exempt from both criteria. The checker does not know how your text is used, so apply those exemptions yourself.

  • Normal text AA: Pass when the ratio is 4.5:1 or higher
  • Large text AA: Pass when the ratio is 3:1 or higher
  • Normal text AAA: Pass when the ratio is 7:1 or higher
  • Large text AAA needs 4.5:1 and has no separate line; read the Normal text AA verdict, which uses the same threshold

Picking a passing color without guesswork

Grey text on white is the classic borderline case. #767676 on #FFFFFF gives 4.54:1 and passes AA; #777777 gives 4.48:1 and fails. If a brand color falls short, adjust its lightness in the HEX, RGB and HSL converter and re-check, because small changes in lightness move the ratio quickly near the threshold.

The ratio describes text against its immediate background. Text placed over a photo or gradient should be checked against the lightest and the darkest areas it crosses, which this tool cannot sample for you.

Limits to know before you rely on it

  • Only hex input is accepted; rgb(), hsl(), named colors and alpha channels are rejected, so semi-transparent text must be flattened to a solid color first.
  • The tool checks text thresholds only. WCAG 1.4.11 Non-text Contrast (3:1 for icons, borders and focus indicators) is not reported as such, though the 3:1 verdict uses the same number.
  • A passing ratio does not make text legible on its own. Font size, weight, letter spacing, screen glare and the reader's vision all matter, and the preview uses the site's font, not yours.
  • The checker cannot sample colors from a screenshot or a live page; you need to know the hex values.

Questions people ask about the Color Contrast Checker

What contrast ratio does WCAG AA require for body text?

WCAG 2.2 success criterion 1.4.3 requires at least 4.5:1 for normal text and 3:1 for large text at level AA. The checker shows both verdicts, so you can see at a glance whether a pair works for headings only or for body copy too.

Can I check a color with transparency?

No. The tool only reads six-digit (or three-digit shorthand) hex colors. If your text uses rgba() or an eight-digit hex, work out the flattened color over its background first, then enter that solid value.

Why does the ratio stay the same when I swap the colors?

The WCAG formula always divides the lighter color's luminance by the darker one's, so a pair has one ratio regardless of which is text and which is background. Swapping only changes the preview and helps you check an inverted theme.

Does the checker cover icons, borders and focus rings?

Not directly. Those fall under success criterion 1.4.11 Non-text Contrast, which asks for 3:1 against adjacent colors. The Large text AA verdict uses the same 3:1 threshold, so you can read it as an informal proxy, but the exemptions differ.

Are my colors sent to a server?

No. The luminance and ratio are computed in your browser by a few lines of JavaScript, and nothing is stored. Once the page has loaded it keeps working without a connection.

Which hex formats are accepted?

Three-digit shorthand such as #FFF, which is expanded to #FFFFFF, and six-digit values such as #17132A. The leading # is optional and case does not matter. Anything else, including four- or eight-digit hex with alpha, shows an error message.

Sources and further reading