Free Contrast Ratio Calculator
Enter two colors to check contrast ratio
What Is a Color Contrast Ratio?
The color contrast ratio is an objective numeric measure of the difference in perceived brightness between two colors—usually the foreground text and the background behind it. It is calculated from the relative luminance of each color and yields a value between 1 (no contrast) and 21 (maximum contrast, like black text on a white background). This metric sits at the heart of the WCAG contrast checker standards and is essential for anyone building an accessible website or application.
For instance, yellow text on a white background produces a very low ratio because both hues have similar luminance, making the content hard to read for many people. Swap the background to black, and the ratio skyrockets, improving legibility dramatically. The human perception of brightness is subjective, but the contrast ratio removes personal bias by providing a single, repeatable benchmark.
Relative Luminance: The Core Component
Relative luminance (RL) normalizes how bright a color appears within a given color space, most commonly sRGB. To compute it, the sRGB channel values must be linearized (gamma decoded) and then weighted according to the eye’s sensitivity to each primary:
Here , , and are the linear sRGB components scaled from 0 to 1. The coefficients reflect that green contributes most to perceived brightness, red less, and blue the least. Note that “brightness” is a subjective impression, whereas relative luminance is an objective, quantifiable value.
How the Contrast Ratio Is Calculated
The WCAG‑specified formula for the contrast ratio is:
Where:
- is the relative luminance of the brighter color (higher value),
- is the relative luminance of the darker color (lower value),
- is a constant that models ambient light contribution.
If you already know the relative luminance of both colors, applying this formula gives you the contrast ratio directly. If you only have the color codes (HEX, HSL, sRGB, etc.), you must first convert them to sRGB and then compute the RL values using the linearization and weighting steps described above. Doing this manually for many color pairs can be tedious, which is why a dedicated color contrast checker automates the entire workflow.
WCAG Conformance Levels: What Is a Good Ratio?
The Web Content Accessibility Guidelines define two conformance tiers:
- AA (minimum)
- Standard text (smaller than 18 pt or 14 pt bold): at least 4.5 : 1
- Large text (18 pt or larger, or 14 pt bold and larger): at least 3 : 1
- AAA (enhanced)
- Standard text: at least 7 : 1
- Large text: at least 4.5 : 1
These thresholds ensure that content remains readable for users with moderate vision loss, color vision deficiencies, or uncorrected refractive errors. A good color ratio calculator will instantly compare your result against these levels and tell you whether the combination passes.
Using the Color Contrast Checker Online
This accessibility color checker offers two input modes to match your workflow:
- From color codes – Choose the color model (sRGB, HEX, HSL, etc.), enter the values for the foreground and background colors, and select the text type (standard or large). The tool returns the contrast ratio and a clear pass/fail indicator for WCAG AA and AAA.
- From relative luminance – Switch to the RL mode, input the two numeric luminance values, and the calculator determines which is lighter before applying the formula. The result is displayed alongside the same conformance message.
Beneath the main result, you can also view the computed relative luminance of each color, helping you understand why a particular combination performs the way it does.
Color Contrast Ratio vs. Display Contrast Ratio
Although the terms are sometimes used interchangeably, the color contrast ratio used in web accessibility and the contrast ratio quoted for monitors and projectors are different metrics. Web contrast is based on relative luminance and is capped at 21 : 1. Display contrast compares the brightest white to the darkest black the hardware can produce and can reach values like 1,000,000 : 1. The tool you are using here is exclusively a web accessibility tool that follows the WCAG method.
Conclusion
Whether you are a developer, designer, or content creator, checking color combinations against accessibility standards is a critical step in building inclusive digital products. This Contrast Ratio Calculator (or WCAG contrast checker) streamlines the process by converting arbitrary color inputs into a reliable ratio and comparing it to the official WCAG thresholds. It removes guesswork and ensures your design choices meet the needs of the widest possible audience.
FAQ
1. What is the minimum contrast ratio for WCAG AA compliance?
For standard text (smaller than 18 pt or 14 pt bold) the minimum is 4.5:1. For large text (18 pt or larger, or 14 pt bold and larger) it is 3:1.
2. How do I calculate the contrast ratio if I only have HEX color codes?
You can use the color contrast checker to do it automatically. The tool converts the HEX values to sRGB, linearizes them, calculates relative luminance, and then applies the formula (RL_lighter + 0.05) ÷ (RL_darker + 0.05).
3. What is the difference between AA and AAA contrast ratios?
AA is the minimum acceptable level (4.5:1 for standard text, 3:1 for large text). AAA is a stricter, enhanced level that requires at least 7:1 for standard text and 4.5:1 for large text, ensuring better readability for users with lower vision.
4. Is the contrast ratio the same as the display contrast ratio on monitors?
No. Web contrast ratio is based on relative luminance and ranges from 1 to 21. Display contrast ratio (for TVs and monitors) compares peak white to the darkest black and can reach millions to one. They measure different things and are not interchangeable.
5. What does a contrast ratio of 1:1 mean?
A ratio of 1:1 means the two colors have identical relative luminance—no contrast at all. This makes text virtually unreadable regardless of color choice.
How to Use
- Choose your input mode - enter hex color codes or relative luminance values.
- Enter the two colors you want to compare. The tool will automatically detect which is lighter and darker.
- View the contrast ratio and WCAG compliance levels instantly. Green badges mean your color combination passes accessibility standards.