Color Contrast Checker

Calculate color contrast ratios according to WCAG 2.1 & 2.2 accessibility guidelines. Test foreground and background colors in HEX, RGB, or HSL with instant AA/AAA ratings, live UI previews, and smart suggestions. 100% private in-browser.

Loading Color Contrast Engine...

What is Color Contrast and Why Does It Matter?

Color contrast refers to the difference in visual luminance (perceived brightness) between text or graphic elements and their surrounding background. High color contrast makes digital content effortless to read, whereas low color contrast causes eye strain and renders websites unusable for millions of users worldwide.

Ensuring adequate color contrast is a fundamental principle of modern web accessibility (a11y) and user experience (UX) design. It benefits users with low vision, aging eyes, color blindness (such as deuteranopia or protanopia), as well as mobile users viewing screens in bright outdoor sunlight.

How WCAG Calculates Contrast Ratios

The World Wide Web Consortium (W3C) establishes contrast rules under the Web Content Accessibility Guidelines (WCAG 2.1 & 2.2). Contrast is expressed as a ratio ranging from 1:1 (identical colors with zero contrast) up to 21:1 (pure black text on a pure white background).

Mathematical Formula:

Contrast Ratio = (L1 + 0.05) / (L2 + 0.05)

Where L1 represents the relative luminance of the lighter color and L2 represents the relative luminance of the darker color. Relative luminance is calculated by linearizing sRGB red, green, and blue values: L = 0.2126Rlin + 0.7152Glin + 0.0722Blin.

WCAG Compliance Standards: AA vs. AAA

Depending on the element type and target compliance level, WCAG defines specific minimum ratio thresholds:

Content TypeLevel AA (Minimum)Level AAA (Enhanced)Description
Normal Body Text4.5 : 17.0 : 1Paragraph copy, blog content, inputs, and small text under 18pt.
Large Text & Headings3.0 : 14.5 : 1Headings 24px+ regular weight or 18.66px+ bold weight.
UI Components & Controls3.0 : 1N/AButton borders, form input outlines, focus indicators, active states.
Graphical Objects3.0 : 1N/AStandalone icons, infographic illustrations, and data charts.

Practical Tips for Designing Accessible Color Palettes

  • Don't rely solely on color: Never use color alone to convey critical status (e.g. error messages should combine red color with an alert icon or text label).
  • Test in dark and light modes: Ensure theme tokens maintain contrast compliance in both light and dark interface contexts.
  • Check placeholder text: Form input placeholders are frequently flagged for failing 4.5:1 body text contrast requirements.
  • Audit focus states: Focus rings and outline indicators must maintain at least 3.0:1 contrast against adjacent background colors.

Frequently Asked Questions

Contrast ratio is calculated using the relative luminance formula defined by the Web Content Accessibility Guidelines (WCAG). Relative luminance (L) measures the relative brightness of any point in a color space, normalized to 0 for darkest black and 1 for lightest white. The contrast ratio is defined as (L1 + 0.05) / (L2 + 0.05), where L1 is the relative luminance of the lighter color and L2 is the relative luminance of the darker color. The resulting ratio ranges from 1:1 (no contrast) to 21:1 (black on white).

WCAG Level AA is the standard legal baseline for web accessibility across most international laws and enterprise guidelines. It requires a contrast ratio of at least 4.5:1 for normal body text and 3:0 for large text or UI components. Level AAA represents enhanced accessibility, requiring at least 7.0:1 for normal text and 4.5:1 for large text. Designing for AAA provides maximum readability for users with low vision or color vision deficiencies.

Under WCAG 2.1 and 2.2 specifications, 'Large Text' is defined as text that is at least 18pt (24px) in regular weight or at least 14pt (18.66px) in bold weight. Because larger fonts are easier to read, WCAG allows a lower minimum contrast ratio of 3.0:1 for Level AA and 4.5:1 for Level AAA.

Yes, 100%. All calculations, color format parsing, luminance evaluation, and suggestion algorithms execute 100% client-side inside your browser using pure local JavaScript. No colors, user inputs, or analytical data are ever sent to ToolZeno servers.

When a chosen color pair fails WCAG AA or AAA requirements, our smart algorithm analyzes the color's HSLA profile. It iteratively adjusts the lightness (L) or brightness of the foreground or background color while preserving the original hue (H) as closely as possible, finding the nearest accessible color shade that meets 4.5:1 or 7.0:1 contrast.