x402AgentsToolsHub

WCAG Contrast Checker

Compute the WCAG 2.1 contrast ratio between a text and background color with pass/fail against every accessibility threshold: AA and AAA for normal and large text, plus the 3:1 UI-component minimum. Exact luminance math — the check every design system needs.

Worked examples

White on emerald

GET /api/v1/media/contrast-check?foreground=%23ffffff&background=%2310b981

Result: 2.54:1 — 0/5 WCAG thresholds pass

Black on white (max)

GET /api/v1/media/contrast-check?foreground=%23000000&background=%23ffffff

Result: 21:1 — 5/5 WCAG thresholds pass

Gray on white (likely fail)

GET /api/v1/media/contrast-check?foreground=%23aaaaaa&background=%23ffffff

Result: 2.32:1 — 0/5 WCAG thresholds pass

Machine API (x402)

$0.002 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol — no accounts, no API keys.

GET /api/v1/media/contrast-check?foreground=%23ffffff&background=%2310b981 HTTP/1.1
Host: agentstoolshub.com

→ 402 (payment required, instructions in headers)
→ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "media/contrast-check",
  "input": {"foreground":"#ffffff","background":"#10b981"},
  "result": { "value": 2.54, "answer": "2.54:1 — 0/5 WCAG thresholds pass" }
}

Agent docs: /llms.txt · OpenAPI spec · integration guide

About this tool

The authoritative WCAG 2.1 contrast computation: relative luminance of both colors, the (L1+0.05)/(L2+0.05) ratio, and pass/fail against all five practical thresholds (AA/AAA, normal/large text, UI components). Deterministic — same colors, same verdict, every audit.

ratio = (L1 + 0.05) / (L2 + 0.05), L = 0.2126R + 0.7152G + 0.0722B (linearized)

Frequently asked questions

What counts as 'large text'?

WCAG: at least 18pt (24px) regular, or 14pt (18.5px) bold. Large text has a relaxed 3:1 threshold because thicker strokes are easier to resolve.

My tool said 4.6, this says 4.55 — which is right?

This one rounds after the full-precision computation (4.55 fails AA's 4.5 cutoff only if it's truly below it). Some tools round the ratio before comparing — that's how failing pairs sneak past.

Related tools