WCAG 2.1 Relative Luminance & AA / AAA Color Contrast Ratio Calculator

Verify WCAG 2.1 AA (4.5:1) and AAA (7.0:1) text accessibility contrast ratios.

WCAG 2.1 Contrast Ratio 7.46 : 1
Margin vs. WCAG AA Normal Text (4.5:1) 2.96 pts
Margin vs. WCAG AAA Normal Text (7.0:1) 0.46 pts
Margin vs. UI / Large Text (3.0:1) 4.46 pts
Inputs
Try:
L₁ (0–1)
Relative luminance of lighter color L₁ (0.00 pure black to 1.00 pure white).
L₂ (0–1)
Relative luminance of darker color L₂ (0.00 pure black to 1.00 pure white).
Results & Graph
WCAG 2.1 Contrast Ratio
7.46 : 1
Margin vs. WCAG AA Normal Text (4.5:1)
2.96 pts
Margin vs. WCAG AAA Normal Text (7.0:1)
0.46 pts
Margin vs. UI / Large Text (3.0:1)
4.46 pts

WCAG 2.1 Contrast Ratio

Graph 1 • How the inputs feed WCAG Contrast Ratio
WCAG 2.1 Relative Luminance & AA / AAA Color Contrast Ratio Calculator • Custom Domain Schematic (Networking & Digital Systems) lighterRdarkerReOut Lighter Relative Luminance: 0.920 L₁ (0–1) • Darker Relative Luminance: 0.0800 L₂ (0–1) WCAG 2.1 CONTRAST RATIO 7.46 : 1 • Margin vs. WCAG AA Nor: 2.96 pts • Margin vs. WCAG AAA No: 0.46 pts Eq: ContrastRatio = (max(L₁, L₂) + 0
Graph 2 • WCAG 2.1 Contrast Ratio as Lighter Relative Luminance changes (40% to 160% of current)
0 : 1 6.56 : 1 13.13 : 1 3.22 0.368 4.63 0.552 6.05 0.736 7.46 0.920 8.95 1.10 10.44 1.29 11.94 1.47
Graph 3 • Lighter Relative Luminance and Darker Relative Luminance together Compares WCAG 2.1 Contrast Ratio when Darker Relative Luminance is shifted +25% (solid) vs. −25% (dashed).
0 : 1 5.33 : 1 10.67 : 1 --- Darker Relative Luminance @ 75% 4.63 -30% 5.55 -15% 6.47 +0% 8.58 +15% 9.70 +30%
Summary: Relative luminance L₁=0.92 against L₂=0.08 produces a 7.46:1 contrast ratio (Passes WCAG AAA (≥7:1)).
Summary: Relative luminance L₁=0.92 against L₂=0.08 produces a 7.46:1 contrast ratio (Passes WCAG AAA (≥7:1)).
Interactive chart & math engine powered by CalculatorGraph

Formula: WCAG Contrast Ratio Systems Engineering Formula

ContrastRatio = (max(L₁, L₂) + 0.05) / (min(L₁, L₂) + 0.05)
ContrastRatio = (max(L₁, L₂) + 0.05) / (min(L₁, L₂) + 0.05)
  • lighterRelativeLuminance: Lighter Relative Luminance (L₁ (0–1))
  • darkerRelativeLuminance: Darker Relative Luminance (L₂ (0–1))

Frequently Asked Questions

Can I type a hex colour into this calculator?

No. Both fields expect relative luminance from 0 to 1. Convert each colour first: scale the channels, remove the sRGB gamma curve, then weight red, green and blue by 0.2126, 0.7152 and 0.0722 and add. Many design tools show this value directly, which saves doing the conversion by hand.

Does a pair at exactly 7 to 1 count as AAA?

Yes. WCAG thresholds are minimums, so a ratio equal to the threshold passes. Luminance 1 against 0.1 gives exactly 7 : 1 and the page reports AAA. In practice, give yourself a small margin above any threshold you need to meet, because real screens and later colour changes rarely land on the exact figure.

Is mid grey on white good enough for body text?

Only just. White at 1 against a grey at 0.18 gives 4.57 : 1, an AA pass for normal text with a margin of about 0.07. It falls well short of AAA and clears the 3 to 1 level easily. A slightly lighter grey, or a thin font, would push it below AA, so treat it as the lightest grey worth using for text.

Which is the lighter luminance if both colours look similar?

It does not matter. The page divides the larger value by the smaller whichever field it is in. Entering the pair in either order gives the same ratio. If the two values are equal, the ratio is 1 to 1, which fails every level.

Do placeholder text and disabled buttons need to pass?

WCAG exempts inactive components such as disabled controls from the contrast rules. Placeholder text inside a field is not exempt if it carries information the user needs. Many designs fail here, because placeholders are deliberately pale. Check placeholders against the field background at 4.5 to 1.

What luminance does a text colour need to pass AAA on white?

About 0.1 or lower. With white at 1, the ratio is 1.05 divided by the text luminance plus 0.05, and that reaches 7 when the text luminance is 0.1. Enter 1 and 0.1 to see the boundary. For AA on white the limit is roughly 0.18.

Does this cover the newer contrast method in WCAG 3 drafts?

No. The page uses the WCAG 2.1 formula only. Draft work on WCAG 3 explores a different contrast model that treats light on dark and dark on light differently and weighs font size and weight. Its numbers are not comparable with these ratios, and current conformance claims still use WCAG 2 figures.

How do I check text over an image?

Find the area of the image behind the text that gives the lowest contrast, often the lightest patch behind light text, and use its luminance as the background. If no spot passes, add a solid or semi-opaque backing behind the text, then blend it and check again.

Why does dark blue text often fail on black but pass on white?

Blue contributes only 0.0722 of luminance, so even a vivid blue has a low value. Against black, which sits at 0, the ratio stays small. Against white it is large. Check the actual luminance rather than trusting how saturated the colour looks on screen.

What does a negative margin tell me?

How many ratio points you are short of that level. At 0.3 against 0.08 the ratio is 2.69 and the margin against the 3 to 1 level is minus 0.31, so the pair fails all three tests. Darken the dark colour or lighten the light one until the margin turns positive.

How much contrast does a chart line or icon need?

Meaningful graphics such as chart lines, icons and input borders fall under the 3 to 1 level for non-text content. That is the third margin on the page. Check each line colour against the chart background, and against neighbouring lines if colour alone tells them apart.

Does the default 0.92 and 0.08 pair suit body text?

Yes. At 7.46 to 1 it passes AAA for normal text with a margin of 0.46, AA with 2.96 to spare, and the 3 to 1 level by 4.46. That makes it a safe body text pairing, though a slightly lighter dark colour would lose the AAA pass quickly. Recheck after each change.

Reading 7.46 to 1 on the default pair

This calculator does not take hex codes or RGB values. It takes two relative luminance figures between 0 and 1, the measure WCAG uses for how bright a colour looks, and turns them into a contrast ratio. The default pairs a very light colour at 0.92 with a dark one at 0.08.

The arithmetic is short. Add 0.05 to each: 0.97 and 0.13. Divide the larger by the smaller: 0.97 divided by 0.13 is 7.46. The page reports 7.46 : 1 and says the pair passes AAA for normal text.

Underneath are three margins, each the ratio minus a threshold. Against the 4.5 AA level for normal text the margin is 2.96. Against the 7.0 AAA level it is 0.46. Against the 3.0 level used for large text and interface parts it is 4.46. A positive margin means a pass. A negative one tells you how far short you are, in ratio points.

That 0.46 is a thin cushion. A small change in either colour, a slightly lighter dark tone or a slightly duller light one, could drop this pair below AAA while leaving AA untouched.

In practice, a light colour near 0.92 is an off-white or very pale tint, and 0.08 is a dark grey or deep colour well short of black. The pairing is typical of body text on a page background, which is why the default sits in AAA territory rather than barely clearing AA.

Why 0.05 is added to both sides

The extra 0.05 stands for flare: the light that bounces off a screen and its surroundings and lifts even pure black above zero. Without it, any colour against pure black would give an infinite ratio, which makes no sense for real viewing.

It also explains the ceiling. White has a luminance of 1 and black 0, so the best possible pair gives 1.05 divided by 0.05, which is 21 to 1. Enter 1 and 0, the black on white preset, and the page returns 21 : 1, with margins of 16.5, 14 and 18 points against the three levels. Nothing can do better. Identical colours give 1 to 1, the floor.

Because 0.05 is fixed, small luminance changes at the dark end matter far more than at the light end. Move the dark colour from 0.08 to 0.2 against 0.92 and the ratio falls from 7.46 to 3.88, losing AA for body text. A similar nudge to the light colour does much less. Dark text and dark backgrounds are where contrast is won or lost.

Getting relative luminance from a colour

Most people start with a hex code, so the luminance has to be worked out first. WCAG defines it in three steps. Convert each of the red, green and blue channels to a 0 to 1 scale by dividing by the channel's maximum value. Undo the sRGB gamma curve: small values are divided by 12.92, larger ones are raised with the standard power formula using 0.055, 1.055 and an exponent of 2.4. Then weight the three channels, 0.2126 for red, 0.7152 for green and 0.0722 for blue, and add them.

The weights are the reason identical-looking colour shifts behave differently. Green contributes most of the brightness the eye sees and blue very little. A saturated blue can have a low luminance even though it looks vivid, which is why blue text on black so often fails.

Skipping the gamma step is the most common mistake. Averaging the raw channel values, or using a simple lightness figure from a colour picker, gives a number that is not relative luminance. Feed that into this page and the ratio will be wrong, sometimes badly.

A quick sanity check: pure white gives 1 and pure black 0. Middle grey, the shade halfway between them by eye, comes out near 0.2, not 0.5, because of the gamma curve. If a mid grey in your workings shows a luminance near 0.5, the gamma step has been skipped.

The thresholds and which text they apply to

The page checks three levels. Normal body text needs 4.5 to 1 for AA and 7 to 1 for AAA. Large text, roughly 18 point regular or 14 point bold and larger, gets a lower bar of 3 to 1 for AA, because bigger letters stay readable at less contrast. The same 3 to 1 level applies to the visible parts of interface components and to meaningful graphics such as icons and chart lines.

The page's verdict line reflects this. At 0.4 against 0.08 the ratio is 3.46 and the verdict is AA for large text only. At 0.3 against 0.08 it is 2.69, and the page says the pair fails even the 3 to 1 level.

Large text at AAA needs 4.5 to 1, the same figure as normal text at AA. The page does not show that as a separate margin, but you can read it from the AA line: any positive AA margin means large text also passes AAA.

Logos and purely decorative text are exempt from the text thresholds, and so is text that is part of a picture with significant other visual content. Everything a user has to read or operate is not. When in doubt, test the pair against 4.5 to 1, because that is the level most audits treat as the baseline for ordinary text.

Swapping text and background makes no difference

The formula always divides the brighter value by the darker one, so the order of the two fields does not matter. Enter 0.08 as the lighter and 0.92 as the darker and the page still returns 7.46 : 1. Dark text on a light background and light text on a dark background score the same.

That does not mean the two look the same. Light text on a dark background can appear to spread or glow, particularly at small sizes and thin weights, and some readers find long passages harder in that mode. The ratio is a minimum standard, not a measure of comfort.

It also means a dark mode palette cannot simply invert a light one and assume the same compliance. The ratio between the two original colours is preserved, but most dark themes change the colours themselves, so each pair needs checking again.

Any colour passes AA against white or black

A useful property falls straight out of the formula. Every colour reaches at least 4.5 to 1 against either pure white or pure black. The crossover sits at a luminance of about 0.18. Enter 0.1791 against 0 and the page gives 4.58 : 1; enter 1 against 0.18 and it gives 4.57 : 1.

So for any brand colour, one of white or black text will pass AA. The middle of the luminance range is the only place where the margin is thin with both.

AAA is different. Against white, a text colour needs a luminance of about 0.1 or lower; against black it needs to be much brighter. No single colour reaches AAA against both, and colours in the middle of the range reach it against neither.

This is a quick way to choose text colour on coloured buttons. Work out the button's luminance once. If it is below about 0.18, use white text; if it is above, use black. Then enter the actual pair on this page to see how much margin you really have, because pure white and pure black are rarely what a design system ends up using.

Boundary cases and rounding

WCAG treats its thresholds as hard minimums. A ratio of 4.49 is a fail at AA even though it rounds to 4.5. The page shows two decimals, which is good enough for most checks, but results sitting right on a threshold deserve care.

Pairs that land exactly on a threshold pass, as the rules intend. Luminance 1 against 0.1 is exactly 7 to 1 and the page reports AAA. Luminance 0.175 against 0 is exactly 4.5 to 1 and the page reports AA. Even so, a design that only just meets the line has no room for a slightly different screen, a colour tweak in a later release or text drawn thinner than planned. Pick a colour with some margin rather than one that sits on the boundary.

Both fields must lie between 0 and 1, because relative luminance cannot be negative or brighter than white. An entry outside that range brings up a message asking for values in range instead of a ratio, which usually means a channel value was typed where a luminance belongs.

Where a single ratio is not enough

The calculation assumes two flat, opaque colours. Text on a photograph, a gradient or a semi-transparent overlay has no single background luminance. Check the worst spot, the lightest area behind light text or the darkest behind dark text, rather than an average.

Transparency needs one extra step. If text or a background uses an alpha value, first blend it with whatever sits beneath to get the colour actually shown, then work out the luminance of that blended colour.

Contrast is also only one part of readable design. Thin fonts, small sizes, tight spacing and colour as the only way to signal meaning can all cause problems at a passing ratio. Use the page to clear the WCAG 2.1 number, then look at the real text on a real screen, in the lighting your users will have.

Focus indicators deserve a separate check. The outline that shows which control has keyboard focus needs to stand out against the colours around it, and the 3 to 1 margin on this page is the one to look at for that. A pale focus ring on a white page often fails while the text itself passes easily.