ContrastChecker

Ensure WCAG accessibility compliance with our live color contrast calculator.

Quick Answer
Read Full Explanation
A contrast checker is a tool that measures the visual contrast between two colors to ensure text is accessible per WCAG guidelines.

Short Answer

A color contrast checker evaluates the luminance difference between text and background colors against WCAG guidelines. By inputting hex/RGB values, it outputs a ratio (1:1–21:1) and pass/fail for AA/AAA levels. This helps designers catch low-contrast issues early, improving accessibility for users with visual impairments.

Detailed Explanation
A contrast ratio quantifies how different two colors are in brightness. It is defined as (L1+0.05)/(L2+0.05), where L1 and L2 are the relative luminances of the lighter and darker colors. Higher ratios mean better readability (21:1 is pure white on pure black). WCAG 2.1 Level AA requires at least 4.5:1 for normal text and 3:1 for large text.
Comprehensive Overview
The Unixly Contrast Checker is a high-performance, client-side utility designed for instant data processing. It provides a standardized and secure format for developers and systems to execute operations directly within the browser, completely avoiding external server requests, latency delays, and potential data privacy risks.
WCAG AA & AAA Instant Evaluation Client Side Processing Free Tool

Color Setup

rgb(255, 255, 255)
rgb(15, 23, 42)

Contrast Ratio

1.00:1

Poor contrast. These colors fail WCAG guidelines and should not be used together for text.

WCAG AA Normal

4.5:1 minimum

FAIL

WCAG AA Large

3.0:1 minimum

FAIL

WCAG AAA Normal

7.0:1 minimum

FAIL

WCAG AAA Large

4.5:1 minimum

FAIL

Live UI Preview

The Quick Brown Fox Jumps Over The Lazy Dog

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Status BadgeActive Item
DashboardSettingsAnalytics
Color Contrast Ratio WCAG AA Checker AAA Compliance Accessible Color Tool Luminance Calculator UI Design Testing Contrast Ratio Formula
Normal Text (AA)≥ 4.5:1
Large Text (AA)≥ 3:1
Normal Text (AAA)≥ 7:1
UI Components≥ 3:1
Max Contrast21:1 (White/Black)
Min Contrast1:1 (Same Color)

What Is Color Contrast?

Definition

In digital design, color contrast is the perceived difference in brightness (luminance) between a foreground element—like text, icons, or borders—and the background color it sits on. A high color contrast ensures that elements stand out clearly, making the content legible.

Why It Matters

For users with normal vision, poor contrast simply causes eye strain. But for individuals with low vision, color blindness, or age-related visual impairments, poor contrast can render a website entirely unusable. Good contrast is a core tenet of inclusive design.

Foreground
Text or Icons
Background
Surface Color
Ratio
Calculated Difference

Key Facts

  • Improves readability for low-vision users
  • Reduces eye strain and improves comprehension
  • Increases user engagement and trust
  • Helps meet legal accessibility standards (ADA)

WCAG Guidelines

WCAG LevelNormal Text ContrastLarge Text ContrastNon-text Elements
AA (Minimum)4.5:13:13:1 (UI elements)
AAA (Enhanced)7:14.5:13:1 (UI elements)

Examples of Pass/Fail

Color PairContrast RatioResult
Black (#000000) on White (#FFFFFF)21:1Pass AAA
Dark Gray (#595959) on White4.5:1Pass AA
Orange (#FFA500) on White2.6:1Fail AA
Adjusted Orange (#E65C00) on White4.7:1Pass AA

Common Mistakes to Avoid

Light Gray on White
Reason: Many designers use light gray for secondary text, which falls below the 4.5:1 threshold.
Solution: Ensure secondary text uses a darker gray shade.
Ignoring Hover States
Reason: Interactive elements change color on hover. The new state may fail contrast requirements.
Solution: Test both the default and hover/active states.
Dark Mode Inversions
Reason: Colors that work on white often fail against dark gray or black backgrounds.
Solution: Use lighter text variants for dark mode themes.
Color as Sole Indicator
Reason: Relying purely on color to convey meaning (like red for errors) fails color-blind users.
Solution: Include icons or underline text along with color changes.

Developer Code Examples

// Calculate Luminance
function getLuminance(r, g, b) {
  const a = [r, g, b].map(function (v) {
    v /= 255;
    return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
  });
  return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
}

// Calculate Contrast Ratio
function getContrastRatio(l1, l2) {
  const lighter = Math.max(l1, l2);
  const darker = Math.min(l1, l2);
  return (lighter + 0.05) / (darker + 0.05);
}

Calculation Formula

// The WCAG 2.0 contrast ratio formula
Contrast Ratio = (L1 + 0.05) / (L2 + 0.05)

Where:
L1 is the relative luminance of the lighter color.
L2 is the relative luminance of the darker color.
Luminance values range from 0 (pure black) to 1 (pure white).

Best Practices

Ensure normal text meets 4.5:1
Ensure large text meets 3:1
UI components must meet 3:1
Test interactive hover/focus states
Don't rely solely on color
Test all colors in Dark Mode

Common Use Cases

UI Design
Design Systems
QA Audits
Mobile Apps
Web Access
Automation
Frontend
A11y Tests
Compliance
UX Testing

Browser Support

Chrome
Firefox
Safari
Edge
Opera
Mobile Web

Troubleshooting

Problem: Failing AA Ratio
Cause: Colors lack sufficient difference in luminance.
Solution: Adjust the lightness of either the foreground or background color.
Problem: Dark Mode Invisibility
Cause: Using hardcoded text colors instead of adaptive tokens.
Solution: Use CSS variables or Tailwind dark variants for text colors.
Problem: Invalid HEX Error
Cause: Missing the '#' or typing invalid characters.
Solution: Ensure the HEX code contains only 0-9 and A-F.

Glossary

Luminance

The relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white.

Contrast Ratio

A property of a display system, defined as the ratio of the luminance of the brightest color (white) to that of the darkest color (black) that the system is capable of producing.

WCAG

Web Content Accessibility Guidelines. A set of guidelines for making web content more accessible to people with disabilities.

ADA

Americans with Disabilities Act. A civil rights law that prohibits discrimination against individuals with disabilities.

HEX Color

A six-digit hexadecimal representation of an RGB color, commonly used in web design.

APCA

Advanced Perceptual Contrast Algorithm. A newer, perceptually uniform method for predicting text contrast readability.

Frequently Asked Questions

General

What is a color contrast ratio?

A color contrast ratio is the numerical difference in luminance between two colors, typically a text (foreground) and its background. It ranges from 1:1 (no contrast, same color) to 21:1 (maximum contrast, pure black on pure white).

What does WCAG stand for?

WCAG stands for Web Content Accessibility Guidelines. It is a set of globally recognized guidelines created by the W3C to ensure digital content is accessible to all users, including those with visual impairments.

What is the difference between WCAG AA and AAA contrast?

WCAG AA is the minimum standard for most websites, requiring a 4.5:1 ratio for normal text and 3:1 for large text. WCAG AAA is the strictest level, requiring a 7:1 ratio for normal text and 4.5:1 for large text.

What is considered large text in WCAG?

WCAG defines large text as text that is at least 18pt (typically 24px) or 14pt (typically 18.66px) and bold.

Usage

How do I use this contrast checker?

Simply paste or select your foreground and background colors in the tool. It instantly computes the contrast ratio and displays Pass/Fail badges for WCAG AA and AAA compliance.

How do I fix low contrast?

If your contrast ratio is too low (e.g., below 4.5:1), you should either darken the text color or lighten the background color (or vice versa in dark mode) until the ratio meets the required threshold.

Do I need to test dark mode colors?

Yes. Colors that pass contrast requirements in a light theme often fail when inverted for dark mode. You must explicitly test your dark mode color palettes to ensure they provide sufficient contrast.

Should I check contrast for hover or focus states?

Yes. Interactive elements like buttons and links change color on hover or focus. These state changes must also maintain a minimum 3:1 contrast ratio against the background and adjacent elements.

Developers

How is the contrast ratio calculated programmatically?

The contrast ratio is calculated using the formula (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. Luminance is calculated after converting sRGB values to linear RGB.

Is there an API for this contrast checker?

Currently, this tool operates entirely client-side for maximum speed and privacy, without requiring API calls. However, you can implement the luminance formula directly in your JavaScript or Python codebase for automated testing.

Accessibility

Why is contrast important for accessibility?

Adequate contrast is critical for users with low vision, color blindness, or age-related visual impairments. Insufficient contrast causes text to blur into the background, making content difficult or impossible to read.

What is non-text contrast?

According to WCAG 1.4.11, non-text contrast applies to UI components (like form inputs and buttons) and graphical objects (like icons). These elements must have a contrast ratio of at least 3:1 against adjacent colors.

References

WCAG 2.1 Guidelines (W3C) MDN Web Docs: Color contrast WebAIM Contrast Checker