Color contrast checker

Pick a text color and a background color to get the WCAG contrast ratio and see whether it passes AA and AAA for normal text, large text and UI components. Free, and it runs in your browser.

How to use it

  1. Choose the Text color and the Background color, or type exact HEX values in the optional fields.
  2. Read the Contrast ratio and the pass or fail result for each WCAG level.
  3. Use the preview to judge how the text really looks, then adjust the colors until the checks pass.

Complete guide to color contrast and WCAG

Why contrast matters

Light gray text on white looks elegant on a designer's bright monitor and becomes unreadable on a phone in the sun, or for anyone with low vision or color blindness. Contrast is the difference in brightness between the text and its background, and it is the single most common accessibility failure on the web. The Web Content Accessibility Guidelines (WCAG 2.x) turn it into a number, the contrast ratio, so that you can test instead of guess. This tool computes the ratio for any two colors and tells you which WCAG levels they meet.

How the ratio is calculated

Each color is first converted to relative luminance, a measure of how bright it appears to the eye. Each red, green and blue value is scaled to 0 to 1, linearized with the sRGB curve, and combined as 0.2126 R + 0.7152 G + 0.0722 B, which reflects that the eye is far more sensitive to green than to blue. The ratio is then (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color and L2 the darker one. It does not matter which color is the text, the ratio is the same. The scale runs from 1:1 (identical colors) to 21:1 (black on white). Everything runs in your browser.

The thresholds the tool checks

LevelMinimum ratioApplies to
AA, normal text4.5:1Body text under 18pt (24px), or under 14pt (about 18.7px) if bold
AA, large text3:1Text of 18pt or more, or 14pt or more in bold
AAA, normal text7:1The stricter level for normal text
AAA, large text4.5:1The stricter level for large text
AA, UI components and graphics3:1Borders of inputs, icons, chart elements

Most laws and policies that mention WCAG ask for level AA, so treat AA normal text as your everyday target.

Worked example

  1. Choose Text color #767676 on Background color #ffffff (or type them in the HEX fields). The ratio is 4.54:1 and 4 of 5 checks pass. It is the lightest pure gray that still passes AA for normal text on white, but it fails AAA for normal text.
  2. Change the text to #777777. The ratio becomes 4.48:1. It looks almost identical, yet it fails AA for normal text and only passes the large text and UI rows, 2 of 5.
  3. Try the default #1f2937 on white. The ratio is 14.68:1 and all 5 checks pass.
  4. Try the blue #3b82f6 on white. The ratio is 3.68:1: fine for large headings and icons, but not for body text.

The preview shows a normal paragraph, a large bold line and a bordered component in your colors so you can judge the real look.

Tips and common mistakes

  • The shown ratio is never rounded up across a threshold: a true 4.497 is displayed as 4.49 and fails, exactly as an audit would treat it.
  • If the optional HEX fields are filled, they replace the color pickers. They accept #abc and #aabbcc; anything else shows an error.
  • Check states too: hover, focus, disabled placeholders and text over images or gradients need their own test, because this tool compares only two flat colors.
  • Pure black on pure white (21:1) can feel harsh for long reading. A dark gray such as #1f2937 keeps a high ratio with less glare.
  • Contrast is one part of accessibility. It does not replace testing with real users and assistive technology.

Related tools

If a pair fails, adjust the lightness with the color converter and its HSL value, or start from a balanced scheme in the color palette generator. To read a color from a screenshot use the image color picker.

Questions

What contrast ratio do I need?

WCAG AA asks for 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold, and up). AAA asks for 7:1 and 4.5:1. UI components and graphics need at least 3:1.

How is the ratio calculated?

Each color is converted to relative luminance with the sRGB formula from WCAG 2.x, then ratio = (lighter + 0.05) / (darker + 0.05). The result goes from 1:1 to 21:1.

Why does 4.49 fail if it looks like 4.5?

The displayed value is never rounded up to reach a minimum. A ratio just under the minimum fails, exactly as an accessibility audit would treat it.

Does this replace a full accessibility audit?

No. Contrast is one part of accessibility. Text over images, gradients and hover states also need to be checked in context.