Colour Contrast Checker

Check the WCAG contrast ratio of a text and background colour pair and see if it passes AA and AAA for normal and large text.

Runs in your browser. Files never leave your device.

Contrast Sample Text

Good contrast makes text readable for users with visual impairments.

Contrast Ratio: 8.33 : 1

AA Normal Text
Requires 4.5:1
Pass
AA Large Text
Requires 3.0:1
Pass
AAA Normal Text
Requires 7.0:1
Pass
AAA Large Text
Requires 4.5:1
Pass

About the Colour Contrast Checker

Check whether text will be readable on its background before a design goes live. Give the checker a text colour and a background colour and it works out their WCAG contrast ratio, then marks whether the pair passes AA and AAA for normal and large text. Run it on button labels, links, banners and form labels, anywhere a brand colour ends up behind text.

Pick each colour with the colour box or type its hex code. A live sample shows a heading and a line of body text in your colours, and the ratio and the four pass or fail marks change as you edit.

How the WCAG contrast ratio is calculated

Each colour is first turned into relative luminance: how bright it looks to the eye on a scale from 0 for black to 1 for white. The red, green and blue values are converted from the curved sRGB scale screens use into linear light, then weighted, because the eye is far more sensitive to green than to blue. That is why pure blue text on black is hard to read even though blue is fully on.

The brighter of the two luminances is divided by the darker one, with 0.05 added to both to allow for glare on a real screen. The result runs from 1:1 (two identical colours) to 21:1 (black on white). It does not matter which colour is the text and which is the background: swapping them gives the same ratio.

channel c = value ÷ 255
linear  = c ÷ 12.92                      if c ≤ 0.03928
        = ((c + 0.055) ÷ 1.055) ^ 2.4     otherwise
L       = 0.2126 × R + 0.7152 × G + 0.0722 × B
ratio   = (L brighter + 0.05) ÷ (L darker + 0.05)

At level AA, WCAG 2.1 wants body-size text at 4.5:1 or more and large text at 3:1 or more; the stricter AAA level raises these to 7:1 and 4.5:1. Large text means about 24px and up at regular weight, or about 18.7px and up in bold.

Assumptions and limits

  • Colours are read as 3-digit or 6-digit hex codes, such as #fff or #0f172a, with or without the #. Anything else, including colour names, rgb() values and 4- or 8-digit codes with transparency, gets a message under the box, and the ratio and checks wait until the code is fixed.
  • Transparency is not taken into account. For semi-transparent text, work out the colour it actually shows on the background and check that.
  • The pass or fail checks use the exact ratio, never a rounded one, as WCAG requires. The ratio shown is rounded to two decimals, except that a pair a hair below a limit is rounded down, so 4.496:1 shows as 4.49 and fails rather than looking like 4.50.
  • The check is for solid colours. Text over a photo or gradient changes contrast from letter to letter; test the lightest and darkest areas behind the text separately.
  • Contrast is one part of accessibility. Font size, weight, spacing and not relying on colour alone matter too.

Worked examples

Grey body text on white: #767676 vs #777777

#767676 on white is the lightest neutral grey that passes AA for normal text. One step lighter fails, which is why designers often settle on this exact value for secondary text.

#767676 on #ffffff → 4.54 : 1   AA normal ✓  AA large ✓  AAA normal ✗  AAA large ✓
#777777 on #ffffff → 4.48 : 1   AA normal ✗  AA large ✓  AAA normal ✗  AAA large ✗

White text on a blue button

Two common blues give very different results. A mid blue passes AA for any text size, while a lighter blue only passes for large or bold button labels.

#ffffff on #2563eb → 5.17 : 1   passes AA normal and large, fails AAA normal
#ffffff on #3b82f6 → 3.68 : 1   passes AA large only

The default dark theme pair

The starting colours, a light sky blue (#38bdf8) on a near-black navy (#0f172a), reach 8.33:1 and pass all four checks, a comfortable margin for dark-mode text.

Contrast ratios of common colour pairs

Calculated with this tool. ✓ = passes, ✗ = fails.

Text on backgroundRatioAA normal (4.5)AA large (3)AAA normal (7)
#000000 on #ffffff21.00 : 1✓✓✓
#1e293b on #f8fafc13.98 : 1✓✓✓
#595959 on #ffffff7.00 : 1✓✓✓
#6b7280 on #ffffff4.83 : 1✓✓✗
#ffffff on #e11d484.70 : 1✓✓✗
#ff0000 on #ffffff4.00 : 1✗✓✗
#949494 on #ffffff3.03 : 1✗✓✗
#9ca3af on #ffffff2.54 : 1✗✗✗

How to use the Colour Contrast Checker

  1. Set the text colour. Click the Text Color box to pick a colour, or type its hex code in the field next to it.
  2. Set the background colour. Do the same under Background Color; the sample panel repaints in your two colours.
  3. Read the ratio and the four checks. A tick under AA Normal Text means body copy is readable for most people; AA Large Text covers headings and big buttons.

Frequently asked questions

What contrast ratio do I need for WCAG AA?

4.5:1 for normal body text and 3:1 for large text, which is about 24px regular or 18.7px bold and larger. Level AAA raises those to 7:1 and 4.5:1. Most accessibility laws and policies point to AA as the target.

Is pure red text on white accessible?

Not for normal text. #ff0000 on white is 4.00:1, below the 4.5:1 AA limit, though it passes for large headings. A darker red such as #dc2626 is a common replacement when red error messages need to pass at body size.

Does it matter which colour is the text and which is the background?

No. The ratio compares the brighter colour with the darker one, so light text on a dark background and dark text on a light background with the same two colours score exactly the same.

Do buttons, icons and input borders need to pass contrast too?

Yes. WCAG 2.1 asks for 3:1 between user interface parts, such as a button's outline or an icon, and the colours next to them. Use the AA Large Text check here as the 3:1 test for those elements.

Why does light grey placeholder text fail?

Light greys are only slightly darker than white, so their luminance is close and the ratio is small: #9ca3af on white is just 2.54:1. Placeholder text has to meet the same 4.5:1 as other text if users need it to understand the field.

Why are my colours not giving the ratio I expect?

Check that the two codes are the colours your page really shows. A see-through colour, an opacity setting or text drawn over an image changes what the eye sees, so pick the final, solid colour with your browser's developer tools and paste that. While a code is incomplete or mistyped, such as #12g or #12345, the checker names the problem under the box and keeps using the last valid colour in the colour box and sample panel.

Sources

This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.