Skip to content
Popular Calculators
Browse Other calculators

Contrast Ratio Calculator

Check the contrast ratio between text and background colours and whether it passes WCAG AA and AAA for normal text, large text and interface parts.

HEX, rgb(…) or hsl(…).

About the Contrast Ratio Calculator

Text that is hard to read is text that does not get read. Low contrast between text and its background is one of the most common accessibility problems on the web, affecting people with low vision, colour blindness and ageing eyes — and everyone reading a phone in bright sunlight. The Web Content Accessibility Guidelines (WCAG), the international standard for accessible websites, set minimum contrast ratios for text and interface elements.

This contrast ratio calculator checks the contrast ratio between a text colour and a background colour, and whether it passes WCAG AA and AAA for normal text, large text and interface components such as buttons and icons. It also shows each colour's relative luminance.

How to Use the Contrast Ratio Calculator

Enter the text colour and the background colour as HEX (#767676), RGB (rgb(118, 118, 118)) or HSL (hsl(0, 0%, 46%)).

The order does not matter: the ratio is the same either way.

How the Contrast Ratio Is Worked Out

  each channel:    c = value ÷ 255
                   linear = c ÷ 12.92              if c ≤ 0.04045
                          = ((c + 0.055) ÷ 1.055)^2.4   otherwise
  luminance        L = 0.2126 × R + 0.7152 × G + 0.0722 × B
  contrast ratio   = (lighter L + 0.05) ÷ (darker L + 0.05)

The ratio runs from 1:1, for two identical colours, to 21:1, for black on white.

Step-by-Step Example

#767676 grey text on a white background.

  Grey luminance:   0.1812
  White luminance:  1.0000
  Ratio:            (1 + 0.05) ÷ (0.1812 + 0.05)   =  4.54:1
  Normal text:      AA pass (4.5), AAA fail (7)

One step lighter, #777777, gives 4.48:1 and fails AA for normal text.

WCAG Requirements

ContentLevel AALevel AAA
Normal text4.5:17:1
Large text3:14.5:1
Icons, buttons, form borders3:1–

Large text means at least 18 point (24 CSS pixels) in regular weight, or 14 point (about 18.7 pixels) in bold. Decorative text, logos and disabled controls are exempt.

Level AA is the standard most organisations aim for and the level referred to by many accessibility laws and procurement rules. Level AAA is stricter and recommended for text that people must read at length.

Why Luminance Is Not Just Brightness

The eye is much more sensitive to green light than to red, and least sensitive to blue. That is why the formula weights green by 0.7152 and blue by only 0.0722, and why pure blue (#0000FF) on black has very low contrast even though it looks vivid. The linearisation step reverses the gamma curve used to store colours, so the calculation reflects the actual light the screen emits.

Common Problems and Fixes

Light grey text is the most common failure. On white, #767676 is the lightest grey that passes AA for normal text, and about #595959 is needed for AAA.

White text on bright colours such as orange, yellow, light green and medium blue often fails. Dodger blue with white text is only about 3.24:1; black text on it gives 6.49:1. Darken the background or switch to dark text.

Text over images needs a solid or semi-transparent background panel, or a dark overlay, to guarantee contrast wherever the text falls.

Hint text inside empty form fields is often too pale; it needs to meet the same ratio if it carries information.

Beyond Contrast

Good contrast is necessary but not sufficient. Do not rely on colour alone to show meaning — pair red error text with an icon or message, and underline links in body text. Use readable font sizes, and let users zoom without breaking the layout.

Contrast in Dark Mode

Dark themes need the same contrast checks. Pure white text on pure black gives the maximum 21:1, but many designers soften both to reduce glare, such as light grey text on a dark grey background. Check the softened pair still passes: #E0E0E0 on #121212, for example, gives a ratio of about 14.2:1, comfortably above AAA. Muted secondary text in dark themes is where failures usually appear.

Testing Your Whole Design

Check every pairing of text and background in a design, not just the main body text: links, buttons in each state, error messages, captions, table stripes and text on coloured banners. Browser developer tools and design software can flag low-contrast text automatically, and this calculator lets you test any individual pair quickly.

Contrast for Graphics and Charts

WCAG also asks for 3:1 contrast for graphical objects needed to understand content, such as chart lines, icons without text, and the borders of input fields. Bars in a chart should contrast with the background and, ideally, with each other; adding labels or patterns helps readers who cannot tell similar colours apart. The same ratio formula applies, so any two colours can be checked here, including neighbouring chart colours, a line against its background, or an icon against the button it sits on, before the design is built and handed over to developers.

Understanding Your Result

Contrast ratio gives the ratio between the two colours.

Normal text shows whether it passes AA and AAA for normal text.

Large text shows whether it passes AA and AAA for large text.

Interface parts shows whether it meets 3:1 for icons and controls.

Luminance gives each colour's relative luminance.

Worth knowing defines large text.

When Should You Use This Calculator?

Designing a website or app.

Choosing brand colours for text and buttons.

Auditing accessibility.

Checking text over coloured banners.

Designing presentations and documents.

Common Mistakes

Using light grey text on white.

Putting white text on bright colours.

Forgetting hover and focus states.

Relying on colour alone to convey meaning.

Testing only the main text colour.

Frequently Asked Questions

What contrast ratio does WCAG require?

WCAG 2 level AA requires at least 4.5:1 for normal text and 3:1 for large text and interface parts such as buttons and icons. Level AAA requires 7:1 for normal text and 4.5:1 for large text.

What is the lightest grey that passes on white?

#767676 on white has a contrast ratio of 4.54:1, just enough for AA normal text, while #777777 gives 4.48:1 and fails. For AAA normal text on white, the grey must be about #595959 or darker, 7.00:1.

How is contrast ratio calculated?

Each colour's relative luminance is worked out from its linearised red, green and blue values, weighted 0.2126, 0.7152 and 0.0722. The ratio is (lighter + 0.05) ÷ (darker + 0.05), from 1:1 up to 21:1 for black on white.

What counts as large text?

Text at least 18 point, about 24 pixels, or 14 point bold, about 18.7 pixels. Large text is easier to read, so it only needs 3:1 for AA and 4.5:1 for AAA.

Does dodger blue with white text pass?

No for normal text. White on #1E90FF has a contrast ratio of about 3.24:1, which passes AA only for large text and interface parts. Black text on the same blue gives about 6.49:1.

Why does colour contrast matter?

Low contrast makes text hard to read for people with low vision or colour blindness, on phones in sunlight and on poor screens. Good contrast helps everyone, and accessibility laws in many countries refer to WCAG.

Last reviewed September 28, 2026 by the CalculatorPeak editorial team.