Skip to content
PictureToLink logoPictureToLink
Menu

Color contrast checker

Black text on white has a contrast ratio of 21:1, the maximum, while #777777 gray on white is 4.48:1 and just fails WCAG AA for normal text, which needs 4.5:1. Type a text color and a background color as hex codes into this color contrast checker to get the WCAG 2.1 ratio with a pass or fail for AA and AAA.

Change any value and the result updates as you type.

3 or 6 hex digits, with or without the #

Contrast ratio

12.63:1

Passes every WCAG level, including AAA for normal text

AA normal text (4.5:1)
Pass
AA large text (3:1)
Pass
AAA normal text (7:1)
Pass
AAA large text (4.5:1)
Pass
UI components and graphics (3:1)
Pass
Relative luminance of text
0.03310 is black, 1 is white
Relative luminance of background
1
Lighter color
Background (#FFFFFF)
WCAG 2.1 success criteria at this ratio
CriterionMinimumResult
1.4.3 Contrast (Minimum), normal text4.5:1Pass
1.4.3 Contrast (Minimum), large text3:1Pass
1.4.6 Contrast (Enhanced), normal text7:1Pass
1.4.6 Contrast (Enhanced), large text4.5:1Pass
1.4.11 Non-text Contrast3:1Pass

Calculated in your browser; nothing you type is sent or stored. Spotted a wrong result? Tell us.

By Mudasir Ahsan (Founder) · Updated 10 November 2026

On this page

How to use the color contrast checker

  1. Enter the text color as a hex code, for example #333333. Three-digit shorthand such as #333 works too, with or without the #.
  2. Enter the background color the text sits on, for example #FFFFFF.
  3. Read the contrast ratio and the five pass/fail lines under it: AA and AAA for normal text, AA and AAA for large text, and the 3:1 rule for buttons, icons and form borders.

The order doesn't matter. Swapping text and background gives the same ratio, because the formula always puts the lighter color on top. If you only have RGB values, turn them into a code with the RGB to hex converter first; the hex to RGB converter goes the other way. To read a color out of a screenshot or a logo, the color picker from image gives you the hex.

The WCAG contrast ratio formula

This WCAG contrast checker uses the WCAG 2.1 definition of contrast ratio. The ratio is built from the relative luminance of each color, a number from 0 (black) to 1 (white) that models how bright the color looks to the eye:

Contrast ratio = (L1 + 0.05) ÷ (L2 + 0.05)

L1 is the relative luminance of the lighter color and L2 that of the darker one. The 0.05 stands for the light a screen reflects even when it shows black. It is the reason no pair can beat 21:1, and the reason the ratio is written as "something to one".

To get the relative luminance of a hex color:

  1. Split the code into red, green and blue (0 to 255) and divide each by 255.
  2. Linearize each channel, because sRGB values are gamma-encoded. If the value is 0.04045 or less, divide it by 12.92. Otherwise compute ((value + 0.055) ÷ 1.055)^2.4.
  3. Weight the channels by how sensitive our eyes are to them: L = 0.2126 × R + 0.7152 × G + 0.0722 × B.

Green carries most of the weight and blue very little. So white text on pure blue (#0000FF) scores a comfortable 8.59:1, while white on pure green (#00FF00) scores only 1.37:1.

Worked example: #777777 on white

77 in hex is 119, and 119 ÷ 255 = 0.4667. That is above 0.04045, so ((0.4667 + 0.055) ÷ 1.055)^2.4 = 0.1845. All three channels are the same, so L = 0.1845. White has L = 1. The ratio is (1 + 0.05) ÷ (0.1845 + 0.05) = 4.48:1, which misses the 4.5:1 minimum for normal text by a hair. The slightly darker #767676 gives 4.54:1 and passes. That is why such an odd gray turns up in so many design systems.

AA vs AAA contrast: what the WCAG levels mean

Success criterionLevelNormal textLarge textApplies to
1.4.3 Contrast (Minimum)AA4.5:13:1Body copy, labels, links, placeholder text
1.4.6 Contrast (Enhanced)AAA7:14.5:1Sites aiming at the strictest level
1.4.11 Non-text ContrastAA3:1 against adjacent colorsButton and input borders, focus rings, icons, chart lines

The full wording is in WCAG 2.1, Success Criterion 1.4.3. Both levels are measured with the same formula, and AAA is a higher bar.

A 4.5:1 contrast ratio is the number most people need. It is the AA requirement for normal text, and AA is the level that most accessibility laws, procurement rules and audits ask for. AAA (7:1) is usually kept for reading-heavy content or for sites with an older audience. W3C itself says AAA cannot be met for all content, so treat it as a goal and not as a gate.

Two kinds of text are exempt from 1.4.3: text that is purely decorative or part of an inactive control, and text inside a logo or brand name. A disabled button can be low-contrast. The text in a placeholder or a "hint" cannot.

Large text contrast: what counts as large

WCAG defines large text as at least 18 point, or 14 point bold. On the web a CSS point is 1⅓ pixels, so that is about 24px regular or 18.7px bold. Large text needs only 3:1 for AA and 4.5:1 for AAA, because bigger strokes are easier to read at lower contrast. White on pure red (#FF0000, 4.00:1) is fine for a big hero heading and fails for a paragraph.

The font size calculator shows which heading sizes in your type scale are over the 24px line. If your stylesheet uses rem, the px to rem converter translates the sizes.

Non-text contrast: buttons, icons and inputs

Since WCAG 2.1, two more things need 3:1 against the colors next to them. The first is any part of a control you must see in order to use it: a button's edge, an input's border, a checkbox, a focus ring. The second is any graphic needed to understand content, such as an icon without a label or a chart line.

Color contrast for buttons takes two checks. The label needs 4.5:1 against the fill. The fill needs 3:1 against the page background if its edge is what tells you it is a button. Light-gray input borders are the most common failure: #CCCCCC on white is 1.6:1.

Common color pairs and their ratios

TextBackgroundRatioAA normalAAA normal
#000000#FFFFFF21.00:1PassPass
#333333#FFFFFF12.63:1PassPass
#595959#FFFFFF7.00:1PassPass
#767676#FFFFFF4.54:1PassFail
#777777#FFFFFF4.48:1FailFail
#949494#FFFFFF3.03:1Fail (large text only)Fail
#FFFFFF#0000FF8.59:1PassPass
#FFFFFF#FF00004.00:1Fail (large text only)Fail
#000000#FFFF0019.56:1PassPass
#FFFFFF#00FF001.37:1FailFail

#595959 is the lightest gray that reaches 7:1 on white, #767676 the lightest that reaches 4.5:1, and #949494 the lightest that reaches 3:1. Keep those three as ceilings when you pick grays for a light theme.

How to fix a failing pair

Contrast depends on luminance and not on hue. The fix is almost always to make the dark color darker or the light color lighter, and changing the hue rarely helps. Accessible color contrast usually comes from a few small moves:

  • Darken the text by a few hex steps and check again. Moving from #777777 to #767676 was enough to cross 4.5:1 in the example above.
  • Avoid mid-tones for text. A saturated orange or a light blue on white rarely clears 3:1. Use it for large headings, or put it on a dark background.
  • For text over a photo, check the darkest and the lightest points of the image, or add a solid or gradient overlay behind the words.
  • Test dark mode separately. Light text on #121212 behaves differently from dark text on white. Pure white on pure black (21:1) can look harsh, so many dark themes use #E0E0E0 text, which still gives 14.19:1.

A pass isn't the whole job, though. The ratio ignores weight, so a 12 px hairline font at 4.6:1 passes and is still hard to read. WCAG treats text as large from 24 px regular or about 18.7 px bold, and only that text gets the lower 3:1 bar. For body text at 14 px or 16 px, aim above 4.5:1 rather than right at it, because thin strokes look lighter on low-density screens than the formula assumes. The checker also can't see text over a photo or a gradient. There you have to test the worst spot yourself.

Limits of the WCAG 2.x ratio and APCA

The 2.x formula treats the two colors symmetrically and ignores font weight. It sometimes passes thin light text on a dark background that is hard to read, and it fails some dark-on-light pairs that look fine.

The W3C's WCAG 3 working draft explores a new method, the Accessible Perceptual Contrast Algorithm. APCA contrast is scored on a different scale and takes text size and weight into account. It is still a draft and is not a requirement anywhere. This checker reports the WCAG 2.1 ratio, which is what every current standard, audit tool and legal reference uses.

Two more limits apply. The ratio assumes opaque colors, so if your text or background has transparency, flatten it against what is behind it first. And the formula is defined for sRGB. If you work in a wide-gamut color space, read our guide to sRGB and Display P3 color profiles.

Questions and answers

Is a 4.5:1 contrast ratio enough?

Yes for AA, the level most organizations and regulations target. It covers text of any size and is comfortable for most readers. If your audience skews older or reads long passages, pushing body text to 7:1 (AAA) costs little: #595959 on white reaches exactly that.

Does black on white pass WCAG?

Yes. Pure black (#000000) on pure white (#FFFFFF) is 21:1, the highest ratio possible, and it passes AA and AAA at every size. Some designers soften it to #333333 on white (12.63:1) or to #1A1A1A. Both still pass everything with a large margin.

How do I check a button or an icon with the color contrast checker for text and background?

Put the icon or border color in the text box and the color behind it in the background box, then read the "UI components and graphics (3:1)" line. For a filled button, check the label against the fill for text contrast, and the fill against the page for the 3:1 non-text rule.

Why does the checker say white on red fails?

White on pure red (#FF0000) is 4.00:1, or 3.998 before rounding. That is under the 4.5:1 minimum for normal text, though it passes the 3:1 rule for large text and graphics. Red has a low relative luminance (0.2126). To pass with white text you need a darker red such as #C00000, or you keep the red for large headings only.

Does the ratio change in dark mode?

No. The formula is symmetric, so dark text on a light background and the same light color on the same dark background have identical ratios. Perception does change: light text on dark tends to look thinner and brighter. Many teams pick a slightly higher target in dark mode and avoid pure white on pure black.

All image, photo and design calculators