WCAG Color Contrast Checker

About this calculator

Enter a foreground and background HEX color to test their contrast. See whether the pair meets WCAG 2.2 color thresholds for text and non-text components.

Use a final opaque 3- or 6-digit HEX color in each field.

Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

How do you calculate a WCAG contrast ratio?

First convert the red, green and blue sRGB values to linear light. Use the weighted sum to find each color's relative luminance. Divide the lighter luminance plus 0.05 by the darker luminance plus 0.05. The result ranges from 1:1 for identical colors to 21:1 for black and white.

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

WCAG 2.2 defines relative luminance using weights 0.2126 for red, 0.7152 for green and 0.0722 for blue. An sRGB channel at or below 0.04045 is divided by 12.92. Above that value, apply ((channel + 0.055) ÷ 1.055)2.4.

What contrast ratio passes AA and AAA?

UseAAAAA
Normal text4.5:17:1
Large text3:14.5:1
Relevant non-text components3:1—

WCAG's large text threshold is generally at least 18 pt, or 14 pt bold, with equivalent size considerations for some fonts. See the W3C guidance for AA text contrast, AAA text contrast and non-text contrast. For a control or graphic, compare each color that conveys necessary information against its adjacent colors.

Why does #777 on white fail AA for normal text?

#777777 on #FFFFFF gives about 4.478:1, below the 4.5:1 minimum. Rounding it to one decimal place would hide that difference. #767676 on white gives about 4.542:1 and meets the threshold. The calculator checks pass or fail using the full calculated ratio.

Which colors should you enter?

Use the final opaque foreground and background colors visible in the interface. For transparency, gradients or imagery, determine the rendered colors in the relevant state first and check the weakest pair. Passing a color-pair threshold leaves other requirements, such as use of color, keyboard focus and readability, to the actual page review.

Frequently asked questions

Does swapping the foreground and background change the contrast ratio?
No. The formula always divides the lighter luminance by the darker after adding 0.05. The preview shows the two roles separately.
Is a 3:1 contrast ratio enough for normal text?
No. WCAG AA normal text needs at least 4.5:1. The 3:1 minimum applies to large text and relevant non-text comparisons.
Can I use an 8-digit HEX color?
Enter the final opaque 3- or 6-digit HEX value. A color with transparency depends on its backdrop.
Does a passing pair mean my website meets WCAG?
It establishes the numerical threshold for the pair. Evaluate the other colors, states, content and applicable criteria on the actual interface.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.