Color Contrast Checker

Check color contrast ratios against WCAG 2.1 standards. See pass/fail results for AA and AAA levels with live preview and suggestions.

Enter a foreground and background colour to see the contrast ratio and whether it passes WCAG 2.1 accessibility requirements at AA and AAA levels. The tool calculates relative luminance using the W3C formula, shows pass/fail badges for normal and large text, and displays a live preview of your colour combination. Everything runs in your browser.

Ad
Ad

About Color Contrast Checker

How the Contrast Ratio Is Calculated

The WCAG 2.1 contrast ratio formula uses relative luminance - a measure of how bright a colour appears to the human eye, accounting for the fact that we perceive green as much brighter than blue at the same intensity.

The formula is: Contrast Ratio = (L1 + 0.05) / (L2 + 0.05), where L1 is the relative luminance of the lighter colour and L2 is the darker. Relative luminance ranges from 0 (black) to 1 (white), so the contrast ratio ranges from 1:1 (identical colours) to 21:1 (black on white).

To calculate relative luminance from an sRGB colour: linearise each channel (apply gamma correction), then combine as L = 0.2126R + 0.7152G + 0.0722B. The green coefficient (0.7152) is much larger than red (0.2126) or blue (0.0722) because human vision is most sensitive to green light.

WCAG 2.1 Contrast Requirements

LevelText TypeMinimum RatioWhat It Means
AANormal text (<18px or <14px bold)4.5:1Minimum required for most websites
AALarge text (18px+ or 14px+ bold)3:1Larger text is easier to read, so the bar is lower
AAUI components and graphics3:1Icons, borders, form controls
AAANormal text7:1Enhanced accessibility - recommended for body text
AAALarge text4.5:1Enhanced accessibility for headings

AA is the standard that most organisations target and that legal accessibility requirements (like the ADA, EAA, and EN 301 549) reference. AAA is stricter and recommended for long-form reading content, but the W3C acknowledges that it is not always achievable for all content.

What Counts as Large Text?

WeightMinimum SizeIn CSSIn Points
Regular (400)24pxfont-size: 24px or 1.5rem18pt
Bold (700+)18.66pxfont-size: 18.66px or ~1.17rem; font-weight: bold14pt

The "large text" thresholds come from the WCAG specification and are based on research into character recognition at different sizes. Larger characters have more visual detail, making them readable at lower contrast ratios.

Common Colour Combinations and Their Ratios

ForegroundBackgroundRatioAA NormalAA LargeAAA Normal
#000000 (black)#FFFFFF (white)21:1PassPassPass
#333333#FFFFFF12.63:1PassPassPass
#767676#FFFFFF4.54:1PassPassFail
#777777#FFFFFF4.48:1FailPassFail
#AAAAAA#FFFFFF2.32:1FailFailFail
#FFFFFF (white)#0066CC (blue)5.57:1PassPassFail
#FFFFFF (white)#FF0000 (red)3.99:1FailPassFail

Notice that #767676 is the lightest grey that passes AA for normal text on white. This is a useful reference point when choosing "muted" text colours. Pure red (#FF0000) on white actually fails AA for normal text - a common surprise.

Tips for Fixing Failing Contrast

StrategyHowExample
Darken the textReduce lightness of foreground colour#777 to #666 on white: 4.48 to 5.74
Lighten the backgroundIncrease lightness of backgroundDark text on #EEE vs #DDD
Increase text sizeUse large text threshold (3:1 instead of 4.5:1)Headings can use lighter colours than body text
Use bold weightBold text qualifies as "large" at smaller sizes (14pt+)Bold button labels can use 3:1 ratio
Choose a different hueBlue and red have low luminance; yellow and green have highReplace light blue with dark blue

Contrast in Design Systems

SystemApproach to Contrast
Material Design 3Colour roles (on-surface, on-primary) guarantee 4.5:1+ pairing
Tailwind CSSScale from 50-950 - pair 600+ text on white, white text on 600+
IBM CarbonAll colour tokens include WCAG-compliant pairings
Apple HIGSystem colours adjust automatically for light/dark mode

In Tailwind CSS, text-gray-500 (#6B7280) passes AA on white at 4.83:1, but text-gray-400 (#9CA3AF) fails at 2.54:1. This is why accessibility-conscious projects avoid gray-400 for text.

Beyond WCAG 2.1: APCA and WCAG 3

The current WCAG 2.1 formula has known limitations - it can underestimate the perceived contrast of light text on dark backgrounds and overestimate contrast for certain colour combinations. The upcoming WCAG 3.0 standard will use the APCA (Accessible Perceptual Contrast Algorithm) instead, which better models human vision. APCA uses a different scale (Lc values from 0-106) and accounts for text polarity (dark-on-light vs light-on-dark) and font size/weight together. WCAG 3 is still in Working Draft status as of 2026 and is expected to take several more years to reach Recommendation status, so WCAG 2.1 and 2.2 remain the practical baseline for conformance claims.

Why Contrast Accessibility Matters

About 2.2 billion people worldwide have a vision impairment of some kind, per the WHO 2019 World Report on Vision. Low-vision users, people with cataracts, and anyone over 40 (when age-related presbyopia and reduced contrast sensitivity set in) all benefit from higher-contrast interfaces. In the US alone, the CDC estimates over 12 million adults aged 40+ have vision impairment, and that number is growing with the ageing population.

Legal exposure is real too. The DOJ finalised ADA Title II digital accessibility regulations in April 2024, which explicitly require WCAG 2.1 Level AA conformance for state and local government web content and apps by 2026/2027 depending on entity size. The European Accessibility Act (EAA) came into force on 28 June 2025 and requires WCAG-aligned accessibility for most consumer-facing products and services sold in the EU. ADA lawsuits against private businesses for inaccessible websites hit a record high in 2024, with contrast failures cited in a large share of WebAIM's annual Million audit (which consistently finds low contrast on more than 80% of the top million home pages).

Common Contrast Mistakes Developers Make

MistakeWhy It FailsFix
Using placeholder text styling for real contentPlaceholder greys (often #999) fail 4.5:1 on whiteKeep placeholders for placeholders, use #555 or darker for real text
Red error text on whitePure #FF0000 is only 3.99:1 - fails AA normalUse #D32F2F or darker (~5:1) for error messages
Light blue links#1E90FF on white is ~3.5:1 - fails AAUse #0056B3 or darker (~5.5:1) for link text
Brand colour over brand colourPrimary on secondary often fails even if both pass on whiteCheck every pairing that actually renders together
Only checking light modeDark mode pairings have different perceptual contrastAudit both themes - some auto-inverted colours fail
Ignoring hover and focus statesMuted hover backgrounds reduce text contrast furtherCheck text ratio against the hover background, not default
Text on gradient or image backgroundsContrast varies across the image - worst-case pixel may failAdd a semi-transparent overlay or text shadow

WebAIM's 2024 Million report found that low-contrast text was the most common WCAG failure on the top one million home pages, appearing on 81% of sites. Missing alternative text and empty links rounded out the top three. Contrast is the single highest-leverage accessibility fix most sites can make.

Worked Example: Fixing a Failing Button

Say you have a call-to-action button with white text (#FFFFFF) on a light green background (#A3D977). White has a relative luminance of 1.0; the green works out to about 0.59. The ratio is (1.0 + 0.05) / (0.59 + 0.05) = 1.64:1 - a clear AA failure for any text size.

Option 1 - darken the background to #3E8E41 (a standard "success" green). Relative luminance drops to 0.233, giving (1.0 + 0.05) / (0.233 + 0.05) = 3.71:1. That passes AA Large only. Still not enough for a body-size button label.

Option 2 - darken further to #2E7D32. Relative luminance is about 0.168, giving (1.0 + 0.05) / (0.168 + 0.05) = 4.81:1. That passes AA Normal. If the button label is bold and at least 14pt, Option 1 would have worked - but for a safer default that works regardless of size, Option 2 is the right call. The tool above runs this search automatically and returns the closest hue-preserving shade that hits your target ratio.

How Contrast Interacts With Colour Blindness

About 1 in 12 men (8%) and 1 in 200 women have some form of colour vision deficiency, per the NHS, with red-green deficiency being by far the most common. Contrast ratio alone does not guarantee that colour-blind users can distinguish a red failure message from a green success message - if both have similar luminance, they may look identical under protanopia or deuteranopia. Follow two rules: meet WCAG contrast minimums AND do not rely on colour alone to convey information. Add icons, labels, or patterns alongside colour coding. The Colour Palette Generator can help build swatches that remain distinguishable under simulated colour vision deficiencies.

Contrast Testing in a CI/CD Pipeline

Checking contrast manually is fine for small projects, but larger codebases benefit from automated testing. Popular options include axe-core (used by Deque's axe DevTools, Cypress-axe, and Pa11y), Lighthouse accessibility audits, and WebAIM's WAVE. These tools flag contrast failures at build or CI time before they reach production. A practical setup is running Lighthouse in a GitHub Action on every pull request and failing the build if the accessibility score drops below a threshold (typically 95+). For component-level verification during design, Figma has a built-in contrast plugin, and Stark is a widely used cross-tool audit suite. Tool-level checks catch roughly 30-50% of WCAG issues automatically (per Deque's own research); the rest still require manual review, especially for dynamic content and interaction states.

To convert colours between HEX, RGB, and HSL formats, the Colour Converter handles that. For building full palettes with accessible pairings, the Colour Palette Generator is a good next step. Everything runs in your browser - no data is sent anywhere.

Sources

Frequently Asked Questions

What is a color contrast ratio?

A contrast ratio is a numeric value that describes the difference in brightness between two colors. It ranges from 1:1 (no contrast, identical colors) to 21:1 (maximum contrast, black on white). Higher ratios mean the text is easier to read against the background.

What are the WCAG contrast requirements?

WCAG 2.1 defines two conformance levels. Level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18px bold or 24px regular). Level AAA requires 7:1 for normal text and 4.5:1 for large text.

What counts as large text under WCAG?

Large text is defined as 18 points (24 CSS pixels) or larger for regular weight, or 14 points (approximately 18.66 CSS pixels) or larger for bold weight. Large text has a lower contrast requirement because bigger characters are inherently easier to read.

How is the contrast ratio calculated?

The formula uses the relative luminance of each color. Relative luminance accounts for how the human eye perceives brightness across the color spectrum. The ratio is (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color and L2 is the darker.

What should I do if my colors fail the contrast check?

Try darkening the foreground or lightening the background (or vice versa) until the ratio meets the required threshold. This tool shows the exact ratio so you can make small adjustments. Even a small shift in lightness can push a failing pair into compliance.

Link to this tool

Copy this HTML to link to this tool from your website or blog.

<a href="https://toolboxkit.io/tools/color-contrast-checker/" title="Color Contrast Checker - Free Online Tool">Try Color Contrast Checker on ToolboxKit.io</a>