User Rating 0.0
Total Usage 0 times
Category CSS Tools
Presets:
Ratio
Level Normal Text Large Text
AA
AAA

Normal text sample — The quick brown fox jumps over the lazy dog. (16px)

Large text sample (24px)

Bold 14pt sample (18.66px bold)

Is this tool helpful?

Your feedback helps us improve.

About

Insufficient color contrast is the most common accessibility violation on the web. The Web Content Accessibility Guidelines (WCAG 2.1) define minimum contrast ratios between text and its background: 4.5:1 for normal text (Level AA) and 7:1 for enhanced readability (Level AAA). Large text (18pt or 14pt bold) receives relaxed thresholds. Failing these ratios exposes organizations to legal liability under ADA, Section 508, and EN 301 549. This tool computes the exact contrast ratio CR from the relative luminance L of two sRGB colors using the W3C-specified linearization formula. It does not approximate. Results match the official WCAG reference algorithm to full floating-point precision.

The tool also generates the nearest compliant color when your pair fails a threshold. Note: this calculation assumes colors are rendered on a standard sRGB display. Transparency compositing against unknown backgrounds is not handled. If either color uses alpha, composite it against white first.

contrast checker wcag accessibility color contrast a11y web design ada compliance

Formulas

The contrast ratio between two colors is derived from their relative luminance values. First, each sRGB channel is linearized from its gamma-compressed form:

clin =
{
csRGB12.92 if csRGB 0.04045(csRGB + 0.0551.055)2.4 otherwise

where csRGB is the 8-bit channel value divided by 255. Relative luminance is then:

L = 0.2126 Rlin + 0.7152 Glin + 0.0722 Blin

The contrast ratio CR is computed as:

CR = L1 + 0.05L2 + 0.05

where L1 is the greater luminance and L2 is the lesser. The ratio ranges from 1:1 (identical) to 21:1 (black on white). Variable definitions: csRGB = gamma-compressed channel value in [0, 1]; clin = linearized channel value; Rlin, Glin, Blin = linearized red, green, blue channels; L = relative luminance in [0, 1]; CR = contrast ratio.

Reference Data

WCAG LevelText TypeMin RatioFont Size ThresholdApplies To
AANormal text4.5:1< 18pt (24px)Body copy, labels, inputs
AALarge text3:1 18pt or 14pt boldHeadings, large UI text
AAUI components3:1N/AIcons, borders, focus indicators
AAANormal text7:1< 18ptMaximum readability
AAALarge text4.5:1 18ptEnhanced large text
AA (1.4.11)Non-text contrast3:1N/AGraphical objects, charts
Common Color Pairs & Their Ratios
Black on White21:1Maximum possible contrast
White on White1:1Minimum possible (invisible)
#777 on White4.48:1Fails AA normal by 0.02
#767676 on White4.54:1Lightest gray passing AA normal
#595959 on White7.0:1Darkest gray just passing AAA
Navy (#003366) on White11.1:1Strong accessible dark blue
Red (#FF0000) on White4.0:1Fails AA normal
Green (#00FF00) on White1.37:1Extremely poor contrast
Blue (#0000FF) on White8.59:1Passes AAA
#757575 on #FAFAFA4.36:1Fails AA normal on near-white

Frequently Asked Questions

Pure red has a relative luminance of approximately 0.2126 (since only the R channel contributes at coefficient 0.2126). Against white (L = 1.0), the contrast ratio is roughly 4.0:1, which falls below the 4.5:1 AA threshold. To pass, darken red to approximately #CC0000 (4.63:1).
sRGB is not linear. A pixel value of 128 does not produce half the light of 255. The gamma decompression exponent of 2.4 (with the linear segment below 0.04045) corrects for this. Skipping linearization and averaging raw RGB values directly produces incorrect luminance values, often underestimating contrast for mid-tones by 10 - 30%.
Yes. The formula is color-agnostic. It operates purely on luminance. Two colors can be visually distinct in hue (e.g., blue vs. orange) yet have nearly identical luminance, yielding a ratio near 1:1. Hue difference alone does not guarantee readability for users with low vision or color blindness.
Large text is defined as 18pt (24px) regular weight, or 14pt (18.66px) bold. These thresholds assume a standard serif or sans-serif font. Decorative or thin-weight fonts may need to be treated as normal text even at larger sizes because their stroke width reduces effective contrast.
WCAG does not define contrast for transparent colors directly. You must composite the semi-transparent foreground onto the actual background using the alpha blending formula: Cout = α × Cfg + (1 α) × Cbg. Then test the resulting opaque color against the background. This tool composites alpha colors against white if alpha is detected.
Yes, this is common. A ratio of 5.5:1 passes AA normal ( 4.5) but fails AAA normal ( 7.0). AAA conformance is recommended for long-form reading and critical interfaces (medical, legal, government). Most design systems target AA as the mandatory baseline and AAA as aspirational.