Checking Contrast for Dark Mode Text (WCAG AA and AAA)
Dark mode looks effortless until you actually have to pick the gray that text sits on top of, and the wrong choice either burns a faint afterimage into a reader's eyes or fails WCAG outright. The relative luminance formula this tool runs works exactly the same whether your background is near-black or pure white, but designers regularly get dark-mode pairs wrong in a specific, predictable way: choosing a foreground gray dim enough to feel restful, then discovering it barely clears 3:1 instead of the 4.5:1 body text actually needs.1 A near-black background and a near-white foreground, like #121212 against #e0e0e0, is a safe, comfortably passing starting point worth understanding before you start narrowing the gap for aesthetic reasons.
Why dark mode tempts you toward failing contrast more than light mode does
Light-mode text almost always defaults toward black on white, a pairing so extreme that most designers would have to work hard to make it fail. Dark mode flips that instinct on its head, because pure white text on pure black can feel harsh and glary, especially in a dim room, so many interfaces deliberately soften both ends toward gray.
The gray-on-gray trap that fails more often than it should
That softening is exactly where trouble starts. A designer who lightens black to a comfortable charcoal and dims white to an easy-on-the-eyes off-white can end up with two colors that sit much closer together in relative luminance than either extreme would, sometimes without realizing how far the ratio dropped. Because both colors moved toward the middle of the brightness range at once, the contrast gap shrinks from both directions simultaneously, which is a faster way to fail than dimming just one side.
A safer approach keeps the background genuinely dark, close to true black, while giving the foreground more room to breathe than it would need against pure white. Material Design's widely used dark-theme baseline of a #121212 background against roughly 87% white text works for exactly this reason:2 the background stays dark enough to avoid glare while the foreground stays light enough to clear AAA with room to spare.
Testing your own dark palette before you commit to it
Type your candidate background and text colors into the fields above and read the Normal Text row specifically, since that is the threshold most of your body copy actually needs to clear. The Large Text row still matters for headings inside the same dark palette, but it is a separate, more forgiving check worth reading on its own.
If the badge shows a fail or a bare AA pass and you'd rather have more headroom, click Fix text to see the closest lighter foreground that reaches AAA without drifting off your original hue, which the tool's OKLab-based search handles automatically,3 letting you keep the same general gray rather than jumping to an unrelated color.
Reading the ratio for an #e0e0e0-on-#121212 pair
Type #e0e0e0 into the foreground field and #121212 into the background field above and the badge clears every WCAG tier by a comfortable margin, including AAA's stricter 7:1 requirement for normal text.4 Swap the two around with the Swap button and the result stays every bit as comfortable, since the ratio treats foreground and background symmetrically.
Why this specific pairing has so much room to spare
That headroom exists because both colors sit near the extremes of the brightness range rather than compromising toward a shared middle gray. The background's near-black luminance and the foreground's near-white luminance stay far enough apart that even a slightly different gray on either side would likely still pass, which gives you real flexibility to warm or cool the palette slightly for brand reasons without risking a fail.
Treat a result this comfortable as a ceiling you can spend, not a target you need to hit exactly, since a slightly softer pairing that still clears AA is often more pleasant to read for long stretches than the maximum-contrast version.5 Use the ratio number above to decide how much of that ceiling you actually want to spend on any given screen.
When to use this
Use this guide whenever you are picking or auditing text colors for a dark-mode interface, and want to confirm a specific foreground and background pair before it ships rather than relying on how restful the pairing looks at a glance.
Examples
A Material Design-style dark card: light text on a near-black background
Foreground #e0e0e0, background #121212
Both colors plug directly into the formula above and clear every WCAG tier, including AAA, since the near-black background and near-white foreground sit far apart in relative luminance.
This is the pairing discussed in the Reading the ratio section above.
A muted gray-on-charcoal pair that looks restful but fails normal text
Foreground #757575, background #1e1e1e
The Normal Text row fails AA here, even though both colors read as comfortably dark and readable to the eye, since dimming the foreground reduced the ratio more than it looks like it should have.
Click Fix text above to see the closest lighter gray that reaches AA without changing hue.
- 1.
W3C, "Understanding Success Criterion 1.4.3: Contrast (Minimum)," w3.org, accessed August 2026. https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
- 2.
Google, "Dark Theme," material-design documentation, github.com, accessed August 2026. https://github.com/zhonghaohu/material-design/blob/master/docs/theming/Dark.md
- 3.
Björn Ottosson, "A Perceptual Color Space for Image Processing," bottosson.github.io, December 2020. https://bottosson.github.io/posts/oklab/
- 4.
W3C, "Web Content Accessibility Guidelines (WCAG) 2.1," w3.org, May 2025. https://www.w3.org/TR/WCAG21/
- 5.
"Dark mode," Wikipedia, accessed August 2026. https://en.wikipedia.org/wiki/Light-on-dark_color_scheme