Dark Mode Contrast Tester

Check that your colour pairs meet WCAG in both light and dark themes simultaneously

Ad placeholder (leaderboard)

The Dark Mode Contrast Tester evaluates a light-theme colour pair and a dark-theme colour pair at the same time, computing the WCAG 2.1 contrast ratio for each and showing AA and AAA pass/fail side by side. Dual-theme design systems are easy to regress: a text colour that reads comfortably in light mode can drop below the threshold once inverted for dark mode. Checking both pairs together catches that before it ships.

How it works

The tool uses the exact WCAG 2.1 relative-luminance and contrast formulas.

  1. Relative luminance. Each sRGB channel is divided by 255 and gamma-expanded (c/12.92 below 0.03928, otherwise ((c+0.055)/1.055)^2.4), then combined as 0.2126·R + 0.7152·G + 0.0722·B.
  2. Contrast ratio. For a pair it computes (Llighter + 0.05) / (Ldarker + 0.05), giving a value between 1:1 (identical) and 21:1 (black on white).
  3. Thresholds. Each theme is checked against the WCAG levels:
Text sizeAAAAA
Normal4.5:17:1
Large (>=18.66px bold / 24px)3:14.5:1

Both themes are reported together so a fail in either stands out immediately.

Tips and notes

  • If a theme fails, the fastest fix is to push the foreground and background further apart in lightness while keeping the hue — small lightness changes move the ratio a lot.
  • Large text gets a lower bar (3:1 for AA), so headings can use colours that body text cannot.
  • Remember criterion 1.4.11: icons, borders, and form-field outlines need at least 3:1 against their background in both themes, not just text.
Ad placeholder (rectangle)