Skip to the content

Contrast Checker

Check text and background colors against the WCAG contrast rules.

HEX, rgb, hsl, oklch or a color name.

HEX, rgb, hsl, oklch or a color name.

Contrast ratio

5.69:1

Enough for text of any size at level AA. At level AAA only large text passes.

WCAG requirementAAAAA
Normal textanything smaller than large textPassneeds 4.5:1Failneeds 7:1
Large textfrom 24 px, or bold from about 18.7 pxPassneeds 3:1Passneeds 4.5:1
Interface components and graphicsfield borders, icons, chart linesPassneeds 3:1no AAA rule
Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What the ratio measures

The contrast ratio compares how much light two colors give off. Each color gets a relative luminance from 0 (black) to 1 (white), and the ratio is

(L1 + 0.05) ÷ (L2 + 0.05)

where L1 belongs to the lighter color. It runs from 1:1 for two identical colors to 21:1 for black on white, and it is the same whichever of the two is the text.

Luminance is not the average of red, green and blue. Each channel is first converted from its 0 to 255 value to linear light and then weighted: L = 0.2126 × R + 0.7152 × G + 0.0722 × B. Green counts about ten times as much as blue, which is why pure blue text on white reaches 8.59:1 and pure green on white gets no further than 1.37:1.

A worked example

Take the gray #767676 on white. Each channel is 118, and 118 ÷ 255 = 0.46275. In linear light that is ((0.46275 + 0.055) ÷ 1.055) ^ 2.4 = 0.1812, which is also the luminance, because the three channels are equal. White has a luminance of 1, so the ratio is 1.05 ÷ 0.2312 = 4.54:1. One step lighter, #777777, comes to 4.47:1.

What WCAG asks for

Level AALevel AAA
Normal text4.5:17:1
Large text3:14.5:1
Interface components and graphics3:1no requirement

Text counts as large from 18 pt, which is 24 px, or from 14 pt when it is bold, about 18.7 px. The text rules are success criteria 1.4.3 and 1.4.6; the rule for everything that is not text is 1.4.11, added in WCAG 2.1. Logos, disabled controls and purely decorative text are exempt.

The limits are thresholds. WCAG says the calculated ratio must not be rounded, so 4.499:1 does not meet 4.5:1. That is why the number here is cut off after two decimals, and why the gray above shows as 4.47:1 where tools that round say 4.48.

Components and graphics

The 3:1 rule covers what someone has to see to recognize a control and its state: the border of a text field, the tick in a checkbox, a focus ring, an icon that carries meaning, the lines of a chart. It is measured against the color right next to it. A button with a readable label does not need a border that passes as well.

What the number leaves out

  • Stroke thickness. A hairline font at 4.5:1 is harder to read than a regular one, and anti-aliasing renders thin strokes fainter than the color you specified.
  • Dark pairs. The formula is known to overstate contrast when both colors are dark. A pair on a dark background that only just passes deserves a second look.

A newer method, APCA, takes font size and weight into account and treats light text on dark differently from dark text on light. It was developed with WCAG 3 in mind, but WCAG 3 is still a draft and no finished version of WCAG uses APCA.

How this tool decides

A text color with transparency, such as rgba(0, 0, 0, 0.6), is blended with the background first, and the blend is measured. Transparency in the background is left out, because the tool cannot know what lies behind it.

The suggested color keeps the HSL hue and saturation of your text color and moves its lightness in steps of 0.1%, up and down, until the ratio is reached. A color far from the limit can end up close to black or white.

See all 8