DevTools Logo

APCA Contrast Calculator

APCA Contrast Calculator

Measure perceptual contrast with APCA 0.1.9 and compare it with classic WCAG 2.1 ratios.

Color and type settings

Choose text and background colors. APCA is directional, so their order matters.

Examples

Black on white reference

Input
analyzeApca("#000000", "#ffffff")
Output
lc ≈ 106, polarity: dark-on-light, wcagRatio: 21

The maximum-practical pair sits at the top of the 0–108 Lc scale with the familiar 21:1 WCAG ratio.

Identical colors

Input
calculateApca({ r: 17, g: 34, b: 51 }, { r: 17, g: 34, b: 51 })
Output
0

Zero luminance delta short-circuits to Lc 0 with equal polarity — no contrast at all.

About this tool

APCA Contrast Calculator implements the APCA 0.1.9 Lc score with calculateApca(text, background): sRGB channels linearize with a 2.4 TRC, near-black luminances below 0.022 get a soft-clamp lift, then the dark-on-light path (exponents 0.56/0.57) or the light-on-dark path (0.65/0.62) produces a signed SAPC value with a 0.027 noise gate, reported as an absolute Lc clamped to 0–108.

Polarity is explicit, not symmetric: getApcaResult returns dark-on-light, light-on-dark, or equal alongside the Lc, the WCAG 2.1 contrast ratio from calculateWcagContrast, and a 4.5:1 pass flag — black on white lands near Lc 106 with a WCAG ratio of exactly 21:1, while identical colors score Lc 0.

Typography-aware guidance comes from getContrastRecommendations(lc, fontSizePx, fontWeight): regular text needs bronze 60 / silver 75 / gold 90 Lc, while large-or-bold text (24px+, or 18px+ at weight 700+) needs 45 / 60 / 75. parseHex accepts 3- and 6-digit hex with or without #, and analyzeApca bundles parsing, scoring, and recommendations with a friendly error for invalid hex.

How to use this tool

  1. Enter two hex colors

    Provide text and background hex (e.g. #000000 on #ffffff) — 3-digit shorthand works and invalid input returns an error instead of a score.

  2. Read Lc and polarity

    Compare the Lc against the bronze/silver/gold minimums and note the polarity, since dark-on-light and light-on-dark use different scoring paths.

  3. Adjust for typography

    Pass the real font size and weight: 24px+ (or 18px+ bold) unlocks the lower large-text minimums of 45/60/75.

  4. Cross-check WCAG ratio

    Use the bundled wcagRatio (21 for black on white) when a project still requires WCAG 2.1 4.5:1 conformance alongside APCA.

Use cases

Checking body-text contrast

Score dark-on-light UI text against the 60/75/90 Lc minimums before committing to a gray palette.

Validating dark-mode pairs

Score light-on-dark combinations on their own polarity path instead of assuming symmetry with the inverted pair.

Documenting dual compliance

Report APCA Lc for readability research and the WCAG ratio for legal conformance from a single analysis call.

Common mistakes

Mistake:Assuming white-on-black scores the same as black-on-white.

Fix:The two polarities use different exponents, so magnitudes differ slightly — always score the pair in its actual text/background order.

Mistake:Treating Lc like a WCAG ratio.

Fix:Lc runs 0–108 with its own bronze/silver/gold minimums; a 4.5:1 WCAG pass does not imply any particular Lc level.

Mistake:Feeding malformed hex and reading the score anyway.

Fix:parseHex returns null and analyzeApca returns { error } for input like #12xz34 — check for the error field before trusting lc.

Frequently asked questions

What does this tool do?

It scores text/background pairs with the APCA 0.1.9 Lc metric (0–108, with explicit dark-on-light or light-on-dark polarity), the WCAG 2.1 contrast ratio, and bronze/silver/gold recommendations adjusted for your font size and weight — black on white scores about Lc 106 at 21:1.

Why do inverted pairs score differently?

APCA uses different exponents per polarity (0.56/0.57 for dark-on-light, 0.65/0.62 for light-on-dark) with a 0.027 noise gate, so white-on-black and black-on-white have slightly different magnitudes. Always score the pair in its real text/background order.

Is my color data uploaded or stored?

No. Hex parsing, luminance linearization, and scoring run entirely in your browser — nothing you enter is sent anywhere.

What counts as large text for the lower minimums?

24px or larger at any weight, or 18px and up at weight 700+, which drops the bronze/silver/gold minimums from 60/75/90 Lc to 45/60/75 Lc.

References & standards