Contrast Ratio Calculator (WCAG)
Colour 1 (e.g. text)
Colour 2 (e.g. background)
- Linearise each sRGB channel and weight them (0.2126 R + 0.7152 G + 0.0722 B): colour 1 luminance = 0.0000, colour 2 luminance = 1.0000.
- Ratio: (1.0000 + 0.05) / (0.0000 + 0.05) = 21.00:1.
- Against WCAG 2.1 thresholds that is AA normal text: Pass, AA large text: Pass, AAA: Pass.
This contrast ratio calculator evaluates two colors and returns the WCAG 2.1 contrast ratio between them, expressed as a value such as 21.00:1. It uses the relative luminance formula L = 0.2126·R + 0.7152·G + 0.0722·B, where each channel is first linearised: c/12.92 if c/255 is at most 0.03928, otherwise ((c/255 + 0.055) / 1.055)^2.4. The ratio itself is (L_lighter + 0.05) / (L_darker + 0.05). The ratio is symmetric, so text and background can be swapped without changing the result, and it ignores hue entirely: two vivid colors of equal luminance score 1:1. For context, black on white gives the maximum ratio of 21.00:1, grey #767676 on white gives 4.54:1 (the lightest grey that passes WCAG AA for normal text, with luminance 0.1812), and pure blue on white gives 8.59:1 because blue contributes only 0.0722 to luminance.
This method is the accepted standard because it is defined by WCAG 2.1, the authoritative accessibility guideline used to judge whether color combinations are readable. The thresholds are specific: AA requires 4.5:1 for normal text and 3:1 for large text, while AAA requires 7:1 for normal text. Large text means at least 18pt, or 14pt bold. This page shows the full formula, step-by-step workings, worked examples, and sources so you can verify every result yourself.
Worked examples
Maximum contrast
Primary result: 21.00:1 — black on white is the highest ratio WCAG defines. (0 · 0 · 0 · 255 · 255 · 255)
| Contrast ratio | 21.00:1 |
| Colour 1 relative luminance | 0.0000 |
| Colour 2 relative luminance | 1.0000 |
| WCAG AA, normal text (needs 4.5) | Pass |
| WCAG AA, large text (needs 3.0) | Pass |
| WCAG AAA, normal text (needs 7.0) | Pass |
The lightest AA grey
Primary result: 4.54:1 — #767676 on white is famous as the lightest grey that still passes AA for normal text. (118 · 118 · 118 · 255 · 255 · 255)
| Contrast ratio | 4.54:1 |
| Colour 1 relative luminance | 0.1812 |
| Colour 2 relative luminance | 1.0000 |
| WCAG AA, normal text (needs 4.5) | Pass |
| WCAG AA, large text (needs 3.0) | Pass |
| WCAG AAA, normal text (needs 7.0) | Fail |
Pure blue on white
Primary result: 8.59:1 — blue's low luminance (0.0722) keeps the ratio high despite the saturated colour. (0 · 0 · 255 · 255 · 255 · 255)
| Contrast ratio | 8.59:1 |
| Colour 1 relative luminance | 0.0722 |
| Colour 2 relative luminance | 1.0000 |
| WCAG AA, normal text (needs 4.5) | Pass |
| WCAG AA, large text (needs 3.0) | Pass |
| WCAG AAA, normal text (needs 7.0) | Pass |
Why luminance, not brightness
A contrast ratio calculator does not look at how bright a color appears to the eye. It works from relative luminance, a weighted measure of how much light each channel emits. The formula is L = 0.2126·R + 0.7152·G + 0.0722·B, where each channel is first linearised: c/12.92 if c/255 is at most 0.03928, otherwise ((c/255 + 0.055) / 1.055)^2.4. Contrast ratio = (L_lighter + 0.05) / (L_darker + 0.05), per WCAG 2.1.
Those three weights reveal why two colors that look equally vivid can produce very different ratios. Human vision is far more sensitive to green than blue, and the formula reflects that. Green gets a weight of 0.7152, while blue gets only 0.0722. Red sits between them at 0.2126. This means a color with a strong green component carries more luminance than one dominated by blue, even when both look equally saturated on screen. The ratio also ignores hue entirely: two vivid colors of equal luminance score 1:1, no matter how different they appear.
Pure blue (0,0,255) on white (255,255,255) shows why relying on perceived brightness would mislead you. Because blue contributes only 0.0722 to luminance, pure blue on white gives 8.59:1 — well above the 7:1 needed for AAA normal text. A saturated color can still contrast well, even when it looks dark against a bright background. For comparison, black on white gives the maximum ratio, 21.00:1, while grey #767676 (118,118,118) on white gives 4.54:1. That grey, with a luminance of 0.1812, is the lightest grey that passes WCAG AA for normal text, which requires 4.5:1.
The ratio is symmetric — text and background can be swapped without changing it. What matters is the luminance gap between the two colors, not which one sits on top. AA requires 4.5:1 for normal text and 3:1 for large text, defined as at least 18pt or 14pt bold. AAA requires 7:1 for normal text. A contrast ratio calculator applies these thresholds to the computed luminance values, not to how the colors feel to the viewer.
Worked examples
The table below shows three verified color pairs that illustrate how the contrast ratio calculator evaluates real combinations. Each pair is processed through the relative luminance formula L = 0.2126·R + 0.7152·G + 0.0722·B, where each channel value is first linearised: c/12.92 if c/255 is at most 0.03928, otherwise ((c/255 + 0.055) / 1.055)^2.4. The contrast ratio is then calculated as (L_lighter + 0.05) / (L_darker + 0.05), per WCAG 2.1.
Black on white produces the maximum possible ratio of 21.00:1, since black has a luminance of 0 and white has a luminance of 1. This pair passes every WCAG threshold with room to spare. Grey #767676 (118,118,118) on white yields 4.54:1, with the grey contributing a luminance of 0.1812. This is the lightest grey that still passes WCAG AA for normal text, sitting just above the 4.5:1 threshold. Pure blue (0,0,255) on white scores 8.59:1, because blue contributes only 0.0722 to luminance, making it far darker to the eye than its RGB values might suggest.
The WCAG verdicts in the table reflect the standard thresholds: AA requires 4.5:1 for normal text and 3:1 for large text, while AAA requires 7:1 for normal text. Large text means at least 18pt, or 14pt bold. Note that the ratio is symmetric — text and background can be swapped without changing the result — and it ignores hue entirely, so two vivid colors of equal luminance would score 1:1.
| Color pair | Lighter luminance | Darker luminance | Contrast ratio | WCAG AA normal text | WCAG AA large text | WCAG AAA normal text |
|---|---|---|---|---|---|---|
| Black (0,0,0) on white (255,255,255) | 1.0000 | 0.0000 | 21.00:1 | Pass | Pass | Pass |
| Grey #767676 (118,118,118) on white (255,255,255) | 1.0000 | 0.1812 | 4.54:1 | Pass | Pass | Fail |
| Pure blue (0,0,255) on white (255,255,255) | 1.0000 | 0.0722 | 8.59:1 | Pass | Pass | Pass |
The AA and AAA thresholds
The WCAG standard sets two conformance levels that our contrast ratio calculator checks against. For Level AA, normal text must reach a contrast ratio of at least 4.5:1 against its background, while large text needs only 3:1. Level AAA is stricter: normal text must hit 7:1. The standard does not define a separate large-text threshold for AAA, so the same 3:1 floor from AA applies.
Large text, as defined by WCAG, means text sized at least 18pt, or 14pt when bold. The lower 3:1 threshold for large text reflects the fact that bigger, heavier letterforms are easier to read even when the contrast is modest. Anything below those sizes counts as normal text and must meet the 4.5:1 (AA) or 7:1 (AAA) requirement.
A useful boundary case is the grey #767676, which has RGB values of (118, 118, 118). On a white background, this grey produces a verified contrast ratio of 4.54:1, with a relative luminance of 0.1812. It is the lightest grey that still passes WCAG AA for normal text. Step even one shade lighter and the ratio drops below 4.5:1, failing AA. This makes #767676 a practical reference point when you want to verify whether a muted color will qualify.
It is worth remembering that the ratio is symmetric, so swapping text and background does not change the result, and the calculation ignores hue entirely. Two vivid colors of equal luminance will both score 1:1, no matter how different they look. That is why a pure blue like (0, 0, 255) on white reaches 8.59:1, comfortably passing AAA for normal text, even though blue contributes only 0.0722 to the luminance calculation. The thresholds are about readability, not color preference.
- AA: 4.5:1 for normal text, 3:1 for large text
- AAA: 7:1 for normal text; large text uses the AA floor of 3:1
- Large text = at least 18pt, or 14pt bold
- #767676 on white = 4.54:1, the lightest AA-passing grey for normal text
Fixing a failing pair
When a pair fails, the fastest fix is to darken the text or lighten the background in small steps. Hue changes alone barely move the ratio, because luminance does the work. The contrast ratio formula, per WCAG 2.1, is (L_lighter + 0.05) / (L_darker + 0.05), where L is relative luminance: 0.2126·R + 0.7152·G + 0.0722·B. Each channel is first linearised: c/12.92 if c/255 is at most 0.03928, otherwise ((c/255 + 0.055) / 1.055)^2.4. Because green carries 0.7152 of the luminance weight and blue only 0.0722, shifting a color toward green nudges luminance far more than shifting it toward blue.
This is why pure blue (0,0,255) on white (255,255,255) gives 8.59:1 — blue contributes so little to luminance that the color stays dark even at full saturation. A contrast ratio calculator will show the same effect: two vivid colors of equal luminance score 1:1, no matter how different their hues appear. The ratio ignores hue entirely and is symmetric, so text and background can be swapped without changing the result.
For practical targets, black (0,0,0) on white (255,255,255) gives the maximum ratio of 21.00:1. Grey #767676 (118,118,118) on white gives 4.54:1 — the lightest grey that passes WCAG AA for normal text, with a luminance of 0.1812. If you need AAA for normal text, aim for 7:1 or higher. For large text, AA requires 3:1 and AAA is not specified here, but the same stepping logic applies.
Work in small increments: darken text by a few RGB units, recheck, and repeat until the ratio clears the threshold you need. Swapping a vivid orange text for a vivid red of equal luminance will not help; dropping the red channel value will.
- AA: 4.5:1 for normal text, 3:1 for large text (at least 18pt, or 14pt bold)
- AAA: 7:1 for normal text
- Maximum ratio: 21.00:1 (black on white)
- Lightest grey passing AA on white: #767676 at 4.54:1
FAQs
How is the WCAG contrast ratio calculated?
Linearise both colours' sRGB channels, compute relative luminance (0.2126R + 0.7152G + 0.0722B), then divide (lighter + 0.05) by (darker + 0.05). Black on white gives 21.00:1.
What contrast ratio do I need for WCAG AA?
You need 4.5:1 for normal text and 3:1 for large text (18pt+, or 14pt bold+). AAA asks 7:1 for normal text. These thresholds ensure text is legible for users with visual impairments.
What is the lightest grey that passes AA on white?
#767676, at 4.54:1 — one step lighter (#777777, 4.48:1) already fails for normal text. That tiny difference matters because the AA threshold for normal text is 4.5:1, so #767676 barely clears it.
Why does pure blue pass easily but yellow fail?
Blue's luminance weight is only 0.0722, so pure blue is 'dark' to the formula (8.59:1 on white); yellow combines the two brightest channels and is very light, scoring under 1.5:1.
Does the order of the colours matter?
No — the lighter luminance always goes on top, so text-on-background and background-on-text give the same ratio. The formula always divides the lighter value by the darker value, so swapping the two colours changes nothing.
Is contrast ratio the whole accessibility story?
No. It covers text legibility only; focus indicators, target size, and not conveying information by colour alone are separate WCAG criteria. A page can pass contrast checks and still be inaccessible if these other requirements are ignored.