Skip to content

Contrast checker

Check a text colour on a background against WCAG 2.2, see them together, and get the closest text colour that passes. Everything runs in your browser, and the link keeps your colours so you can share the result.

Runs in your browserWCAG 2.2AA and AAA

Colours

Hex, such as #1f2937 or #fff.

Hex, such as #1f2937 or #fff.

Result

4.46:1 contrast ratio

Fails AA for normal text, which needs 4.5:1. Large text and UI components pass.

  • Normal text AANeeds 4.5:1 · SC 1.4.3Fail
  • Normal text AAANeeds 7:1 · SC 1.4.6Fail
  • Large text AANeeds 3:1 · SC 1.4.3Pass
  • Large text AAANeeds 4.5:1 · SC 1.4.6Fail
  • UI components and graphics AANeeds 3:1 · SC 1.4.11Pass

Fix it

  • AA (4.5:1)#6365f0 · 4.51:1
  • AAA (7:1)#4a4cb5 · 7.01:1

The closest text colour for normal text, made darker or lighter while keeping its hue.

Preview

Large text, 24 px

Normal body text at 16 px. Most interface text is this size or smaller, so it needs the higher 4.5:1 ratio.

Small text at 14 px, like captions and helper text.

Outlined buttonIcons and borders need 3:1.

The preview is not interactive. It shows your colours as text, an outlined control and an icon.

How it works

The ratio

Each colour gets a relative luminance from 0 (black) to 1 (white), from its linearised sRGB channels: L = 0.2126 R + 0.7152 G + 0.0722 B. The contrast ratio is (lighter + 0.05) / (darker + 0.05), from 1:1 for identical colours to 21:1 for black on white. Ratios are cut to two decimals, never rounded up, so a pair at 4.499:1 shows 4.49 and fails 4.5:1.

What each check needs

WCAG 2.2 contrast thresholds
ContentAAAAACriterion
Normal text4.5:17:11.4.3 and 1.4.6
Large text: at least 24 px, or 18.66 px bold3:14.5:11.4.3 and 1.4.6
UI components and graphics: borders, icons, focus rings, chart lines3:1–1.4.11

Large text is 18 pt (24 px) or 14 pt (about 18.66 px) bold. Text in logos and disabled controls is exempt.

The suggested colours

When a pair fails, the checker mixes your text colour with black or with white in small steps, and suggests the first mix that reaches the target. Whichever direction needs the smaller change wins, so the hue stays close to your original. On a mid-tone background, some targets can't be reached by any text colour; the checker says so.

Not covered yet

  • Transparent colours. Blend them with what's behind them first, then check the result.
  • Text on gradients or images. Check against the lightest and darkest spots behind the text.
  • Colour formats other than hex. The palette generator takes oklch() and gives you the hex.
  • APCA, the contrast method proposed for WCAG 3. It's still a draft, and WCAG 2.2 is what audits and laws refer to today.