Toolical © 2026

Color Contrast

Calculate the contrast ratio between two hex color values based on WCAG AA/AAA guidelines. Check if text is readable on any background color.

Result
Please check your inputs.
Enter the hex color code for your foreground (text) color in the first input field. Enter the hex color code for your background color in the second input field. The tool instantly calculates the contrast ratio and shows whether it passes WCAG AA (4.5:1 for normal text, 3:1 for large text) and AAA (7:1 for normal text, 4.5:1 for large text) standards. Adjust either color until you reach a passing ratio, then copy the result or use the colors in your design.

๐Ÿ“– How to Use This Tool

Enter the hex color code for your foreground (text) color in the first input field.
Enter the hex color code for your background color in the second input field.
The tool instantly calculates the contrast ratio and shows whether it passes WCAG AA (4.5:1 for normal text, 3:1 for large text) and AAA (7:1 for normal text, 4.5:1 for large text) standards.
Adjust either color until you reach a passing ratio, then copy the result or use the colors in your design.

๐Ÿ“ What Is Color Contrast?

Color contrast refers to the difference in luminance between two colors, typically text and its background. The contrast ratio, defined by the Web Content Accessibility Guidelines (WCAG), is a numeric measure that helps ensure content is readable for people with low vision, color blindness, or screen glare. A higher ratio means better readability. This tool calculates that ratio instantly from hex color values, so you can check if your design choices meet accessibility standards before publishing. Prioritizing color contrast is crucial for inclusive designโ€”it directly impacts how easily users can consume your content, especially on mobile screens or in bright environments. By using this tool, you save time guessing and avoid accessibility lawsuits or user frustration.

๐Ÿงฎ Formula

The contrast ratio is calculated 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. Relative luminance is computed from the sRGB color space: for each RGB channel (converted from hex), apply gamma correction (if channel <= 0.03928, linear = channel/12.92; else linear = ((channel+0.055)/1.055)^2.4). Then luminance = 0.2126*R_linear + 0.7152*G_linear + 0.0722*B_linear. The formula accounts for human eye sensitivity to different colors.

๐Ÿ’ก Tips for Best Results

โœจ๐ŸŒ— Use dark text (e.g., #333) on light backgrounds (e.g., #FFF) for the highest contrast ratios โ€” it's a safe starting point.
โœจ๐Ÿ“ Don't forget large text thresholds: WCAG AA requires only 3:1 for text 18pt bold or 24pt regular โ€” you can use slightly lower contrast for headlines.
โœจ๐ŸŽจ Test with simulated color blindness modes to ensure contrast works for red-green deficiencies โ€” a high ratio alone isn't enough if hues clash.
โœจ๐Ÿ”„ Always double-check your brand colors โ€” a beautiful palette that fails AA will alienate 15-20% of users. Adjust shades slightly, not entire hues.

โ“ Frequently Asked Questions

What is the difference between WCAG AA and AAA?
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 a stricter level, needing 7:1 for normal text and 4.5:1 for large text. Aim for AAA if possible, but AA is generally acceptable for compliance.
Can I use this tool for non-text elements like icons or borders?
Yes, WCAG also applies to non-text content that conveys information, such as icons, graphs, and form borders. The same contrast ratio thresholds (3:1 minimum) are recommended. Our tool works for any two hex colors, so you can test UI elements too.
What if my background has a gradient or pattern?
For gradients or patterns, test the worst-case contrast โ€” choose the lightest and darkest spots in the background against your text. Use this tool on those extreme pairs. If both pass, the whole area is safe. Alternatively, use a solid overlay behind the text.

๐Ÿ”— Related Tools