// tool_09

Color Contrast Checker

Check foreground/background color pairs against WCAG 2.1 AA and AAA standards. Instant results, live preview, suggested fixes — no server, no signup.

// updated April 2026
Foreground (text)
HEX value
RGB
rgb(255, 255, 255)
HSL
hsl(0, 0%, 100%)
Luminance
1.000
HEX
#ffffff
Background
HEX value
RGB
rgb(13, 13, 13)
HSL
hsl(0, 0%, 5%)
Luminance
0.002
HEX
#0d0d0d
21.0:1
Contrast ratio
Live preview
The quick brown fox jumps over the lazy dog
Normal body text at 16px — lorem ipsum dolor sit amet, consectetur adipiscing elit. Developers build for everyone.
Small / UI text: font-size: 12px; color: inherit; letter-spacing: 0.02em;
Button
Badge
Suggested foreground colors that pass AA
// common pairs

What is WCAG color contrast?

WCAG (Web Content Accessibility Guidelines) is the international standard for web accessibility, published by the W3C. The contrast requirements in WCAG 1.4.3 ensure that text is readable by people with low vision, colour blindness, or who are viewing screens in bright sunlight.

The standard defines a contrast ratio — a number from 1:1 (no contrast, identical colours) to 21:1 (maximum contrast, black on white). The higher the ratio, the more readable the text.

WCAG AA vs AAA — the full requirements

LevelText typeMin ratioExampleStatus
AANormal text (<18pt / <14pt bold)4.5:1#767676 on whitePASS
AALarge text (≥18pt / ≥14pt bold)3:1#949494 on whitePASS
AAUI components & graphics3:1Button border on backgroundPASS
AAANormal text7:1#595959 on whitePASS
AAALarge text4.5:1#767676 on whitePASS
FailAny text<3:1#aaaaaa on white = 2.32:1FAIL

AA is the legal minimum in most accessibility standards worldwide — Section 508 (US), EN 301 549 (EU), and WCAG 2.1 compliance all require AA. AAA is recommended for text-heavy content like documentation, news articles, and legal text.

How contrast ratio is calculated

The contrast ratio uses relative luminance — how bright a colour appears to the human eye, accounting for the fact that green contributes more to perceived brightness than red or blue.

Contrast ratio formula
// Step 1: convert each channel to linear light
function linearize(channel) {
  const s = channel / 255;
  return s <= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
}

// Step 2: calculate relative luminance (0 = black, 1 = white)
function luminance(r, g, b) {
  return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
}

// Step 3: contrast ratio (always >= 1:1)
function contrastRatio(lum1, lum2) {
  const [hi, lo] = lum1 > lum2 ? [lum1, lum2] : [lum2, lum1];
  return (hi + 0.05) / (lo + 0.05);
}

Most common contrast failures

Check contrast ratio in code

JavaScript — check if a pair passes WCAG AA
function hexToRgb(hex) {
  const n = parseInt(hex.replace('#', ''), 16);
  return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
}
function lin(c) { const s = c/255; return s <= 0.04045 ? s/12.92 : Math.pow((s+0.055)/1.055, 2.4); }
function lum({r,g,b}) { return 0.2126*lin(r) + 0.7152*lin(g) + 0.0722*lin(b); }
function ratio(fg, bg) { const [hi,lo] = [lum(fg),lum(bg)].sort((a,b)=>b-a); return (hi+0.05)/(lo+0.05); }

// Usage
const r = ratio(hexToRgb('#ffffff'), hexToRgb('#0d0d0d'));
console.log(r.toFixed(2));         // → 19.69
console.log(r >= 4.5 ? 'AA PASS' : 'AA FAIL'); // → AA PASS

// wcag 2.1 vs wcag 2.2

WCAG 2.2 (published October 2023) did not change the contrast ratio requirements from 2.1 — 4.5:1 for AA and 7:1 for AAA remain the same. The new criteria in 2.2 added focus indicator requirements and removed the AAA requirement for cognitive accessibility. For contrast purposes, 2.1 and 2.2 are identical.

Read the full guide: WCAG color contrast guide.

// privacy & how it works

This tool runs entirely in your browser using JavaScript. No colours, no data, and no information about your designs are ever sent to any server. The contrast ratio is calculated locally using the WCAG relative luminance formula — the same algorithm used by browser devtools and design tools like Figma.

You can use the Share URL feature to save and share colour pairs — the values are encoded in the URL parameters only.

// frequently asked questions
What is the minimum contrast ratio for WCAG AA?
WCAG 2.1 AA requires a contrast ratio of at least 4.5:1 for normal text (below 18pt or 14pt bold) and 3:1 for large text. UI components and graphical objects also require a minimum of 3:1 against adjacent colours. Full guide: WCAG colour contrast guide.
What is the difference between WCAG AA and AAA?
AA is the standard compliance level required by most accessibility laws and frameworks (Section 508, EN 301 549, WCAG 2.1). AAA is the enhanced level — it requires 7:1 for normal text and is recommended for text-heavy content like documentation or news articles.
Does contrast ratio apply to placeholder text?
Yes — WCAG 1.4.3 applies to all visible text including placeholder text in form inputs. Placeholder text often fails contrast checks because designers use very light grey. The same 4.5:1 minimum applies.
What counts as "large text" in WCAG?
Large text is defined as 18pt (24px) or larger for regular weight, or 14pt (approximately 18.67px) or larger for bold text. Large text has a lower minimum contrast requirement of 3:1 for AA and 4.5:1 for AAA.
Does WCAG contrast apply to icons and borders?
Yes — WCAG 1.4.11 (Non-text Contrast) requires UI components like buttons, inputs, and icons to have at least 3:1 contrast against adjacent colours. This applies to the button border, input outline, and any icon that conveys meaning without a text label.
Can I share a colour pair from this tool?
Yes — click "Share URL" above and the tool generates a shareable link with your colour pair encoded in the URL parameters. You can also bookmark it to save your current pair for later reference.