How the contrast ratio is calculated
Low-contrast text is the most common accessibility failure on the web. Every year since it began, WebAIM's automated survey of the top one million home pages has found insufficient text contrast on roughly four out of five of them, far ahead of missing alternative text or unlabeled form fields.1 Before you can fix a failing pair, it helps to understand exactly what the large number in this tool measures and why two colors that look distinct to you can still score poorly.
The relative luminance formula
The ratio compares the relative luminance of your two colors. Relative luminance is a measure of perceived brightness: the formula undoes the display's gamma encoding for each channel, then weights red, green, and blue by how strongly the human eye responds to each, with green contributing roughly ten times more than blue.2
Both values then pass through (L1 + 0.05) / (L2 + 0.05), where each 0.05 term models the small
amount of light a real screen emits even when showing pure black. As a result, the scale runs
from 1:1 for two identical colors up to a hard ceiling of 21:1 for pure black against pure
white.
When the background is not one color
Real interfaces rarely hand you two flat colors. The ratio exists between exactly two colors, and the guidelines measure it against the specified background the text renders over in normal usage.3 Text on a photograph or a gradient therefore has no single ratio: every region of the backdrop forms its own pair with your text color. The honest method is the worst-case pair. The background region closest in lightness to the text color is where the ratio bottoms out, so sample that region, pair it with the text color, and treat that pair as the one that must clear the threshold. That sampled pair enters this checker like any other flat pair.
A solid backing removes the ambiguity entirely. Placing a scrim, a plate, or a solid band behind the text turns the situation back into two flat colors, and those two colors are what the checker measures directly. The boundary here is equally plain: this tool accepts exactly two flat colors, takes no image or gradient input, and offers no eyedropper, so the sampling decision happens in your design tool before the paste. When the design cannot live without the photo showing through, sample the worst-case region, verify the pair here, and keep the sampled value in your notes.
Semi-transparent colors
Semi-transparent colors hit the same wall. Both fields accept only fully opaque forms:
six-digit hex, shorthand hex, rgb(), hsl(), hsv(),
oklch(), and the CSS named colors all parse, while every alpha-bearing syntax,
from rgba() to eight-digit hex, shows the unrecognized-format hint and keeps the
last valid color. The reason is definitional rather than a missing feature. A translucent
color has no contrast ratio of its own, because what appears on screen depends on what shows
through it, so there is no single pair to measure until the layer is composited.
Flatten the color before you paste it. Composite the translucent layer over its actual
background in your design tool, then check the resulting flat pair here. The arithmetic is
small but worth seeing once: a fifty percent black overlay composited over white produces
roughly #808080, and that gray, not the original rgba() value, is
the color the checker needs paired against the text. One translucent brand tint therefore
produces two different ratios over two different surfaces, which is exactly why the
flattening step cannot be skipped. Check each surface separately whenever the tint spans a
light region and a dark one.
What AA and AAA require for each tier
WCAG 2.1 does not apply one threshold to everything. Body text must reach 4.5:1 for AA conformance and 7:1 for AAA, while large text, defined as at least 24 CSS pixels at regular weight or roughly 18.7 pixels when bold, passes AA at 3:1 and AAA at 4.5:1 because thicker, taller strokes stay legible at lower contrast.4 The three rows in the preview panel mirror those tiers exactly, so the same color pair can pass comfortably as a heading while failing as body copy.
The third row covers something many checkers skip entirely. Under success criterion 1.4.11,
the visual boundaries and states of user interface components, such as a button's outline or
a text field's border, need at least 3:1 against adjacent colors.5
For this criterion, WCAG defines no enhanced AAA tier, which is why the UI row shows a single
AA badge instead of two. If your button borders inherit a muted gray from a design system
default, this row is the one that catches it.
What WCAG is, and what it is not
Behind these badges sits a document, not a law. WCAG, the Web Content Accessibility Guidelines, is a technical standard published by the W3C, and its success criteria are organized into three conformance levels: A, the lowest; AA, the middle tier; and AAA, the highest.6 Each criterion carries its level tag, so "passes AA" always refers to a numbered, testable statement rather than a general seal of approval. The tiers this checker reports are exactly those documented levels, nothing more and nothing less: a badge means one criterion, at one named level, passes for this pair of pixels.
WCAG itself legislates nothing. It is a standard that laws and procurement rules around the world reference, which is a crucial distinction: the binding requirements for any given project come from whichever law, regulation, or policy applies in that context, not from the W3C. Those policies differ by country, scope, and the WCAG version they build on.6 When your project must answer to a regulator rather than a design review, read the policy that governs it, because this checker measures contrast against the standard, not against the law.
Which version should the numbers come from, then? The thresholds on this page are WCAG 2.1's, and the current revision, 2.2, kept every contrast criterion unchanged: 1.4.3, 1.4.6, and 1.4.11 carry the same ratios under both versions. Version 2.2 added new success criteria in other areas, none of them revising the text or non-text contrast ratios this checker measures, so a pair that clears these rows meets the same contrast criteria under 2.2 as well.7 Check your policy for the version it names, and let that decide whether any of the newer criteria need a separate audit.
WCAG Color Contrast Checker
The Color Format Converter has a contrast panel of its own, and its guide to WCAG contrast sits here because this checker is where the ratio, the AA and AAA tiers and Auto-Fix come together. It covers how the ratio is calculated, how to read each level, WCAG 2.2 and its target size criterion, testing contrast in OKLCH before converting to HEX, and the mistakes saturated accent colors cause.
Low contrast fails accessibility guidelines and users with low vision.
WCAG 2.1 sets specific minimum contrast ratios between text and its background: 4.5:1 for normal text at AA level, 3:1 for large text or UI components, and 7:1 for AAA compliance.1 These thresholds exist because users with conditions like cataracts, low vision, or color deficiency depend on sufficient contrast to read text reliably. Checking contrast before committing a color pair to production code prevents the accessibility rework that follows an audit or user complaint.
How WCAG contrast is calculated
The WCAG relative luminance formula first linearizes each sRGB channel by reversing the gamma curve, then computes luminance as Y = 0.2126 × R + 0.7152 × G + 0.0722 × B. The contrast ratio between two luminances L1 and L2 is (L1 + 0.05) / (L2 + 0.05) where L1 is the higher value.1 The 0.05 offset prevents division by zero at black and compresses the ratio at the ends. Consequently, black on white produces the maximum ratio of 21:1, while identical colors produce 1:1, representing zero contrast. Engineers working with the formula directly benefit from memorizing these three anchor points because every real-world contrast value falls somewhere between them.
Reading the WCAG levels
The tool shows contrast ratios for black text and white text placed on your selected color. WCAG defines three thresholds: AA requires 4.5:1 for normal text (below 18pt or 14pt bold) and 3:1 for large text or UI components. AAA requires 7:1 for normal text and 4.5:1 for large text.2 The labels in the contrast panel follow this structure: "AAA" means both thresholds pass; "AA" means normal-text AA passes; "AA LG" means only the large-text 3:1 threshold is met; "Fail" means no threshold is reached. Building on this, the panel with the higher contrast ratio is the better text color choice for the selected background.
Beyond the ratio: practical contrast guidance
A passing contrast ratio is necessary but not sufficient. Very thin fonts need higher contrast than the WCAG minimum to remain readable at small sizes. Pure black on pure white passes AAA at 21:1 but can cause visual fatigue for some users, so off-white backgrounds pairing (#f5f5f5) at 17:1 are often more comfortable with no loss of accessibility. WCAG 2.1 contrast applies to text and meaningful images of text, while three exceptions are carved out: large-scale text at 3:1, incidental text such as inactive UI components and pure decoration, and logotypes.3 Check contrast in the context of the actual rendering environment because ambient light, screen brightness, and font choice all shift the perceived ratio away from the abstract number.
WCAG 2.2 and the new target size criterion
WCAG 2.2 adds Success Criterion 2.5.8 (Target Size) which requires interactive targets to be at least 24 by 24 CSS pixels, with some exceptions for inline links and user-agent controls.2 While this criterion does not directly affect color contrast, it interacts with it in practice: a button that passes contrast at its default size may fail when the touch target is enlarged with padding, because the padding area may have a different background color. Check contrast for the entire interactive area, not just the visible label.
Contrast requirements for focus indicators
WCAG 2.2 also strengthens requirements for focus indicators. A focus ring or outline must have a contrast ratio of at least 3:1 against the adjacent colors on both sides of the boundary.4 This means a blue focus ring on a white background needs to be dark enough to pass 3:1 against white, while the same ring on a dark background needs to be light enough to pass 3:1 against the dark color. Using oklch() to define focus indicator colors lets you set the L channel to a value that guarantees the 3:1 threshold against both your light and dark theme backgrounds.
The 3:1 rule applies to the outline itself, so a thin focus ring drawn in a mid-grey can quietly fail even when the surrounding button passes. Reading the indicator off the adjacent background on both sides is the part teams forget, because a ring that looks fine on the white card may vanish against the colored button it wraps. Setting the ring color from an OKLCH L value keeps the math explicit and lets a single token satisfy light and dark themes at once.
Testing contrast in OKLCH space before converting to HEX
You can estimate WCAG contrast directly from OKLCH L values before converting to HEX. The relative luminance formula in WCAG is a weighted sum of linearized RGB channels, and the OKLab L channel is already a perceptual lightness measure that correlates strongly with WCAG relative luminance.4 A quick check: if the L difference between two OKLCH colors is at least 0.4, the contrast ratio will likely pass AA for normal text. This is an approximation, not a substitute for the full WCAG calculation, but it is useful during design exploration when you are adjusting OKLCH coordinates and want immediate feedback.
Defining accessible token pairs in OKLCH
Defining accessible token pairs in OKLCH means choosing L values that guarantee the required contrast ratio before you commit the tokens to your design system. For AA normal text (4.5:1), ensure the foreground-background L difference is at least 0.4. For AAA (7:1), aim for at least 0.55. Store these as paired tokens: --color-text-primary at L=0.20 paired with --color-bg-primary at L=0.95 gives a contrast ratio above 15:1, well exceeding AAA. When you need to create a dark mode variant, swap the L values: --color-text-primary at L=0.90 over --color-bg-primary at L=0.12 preserves the same L difference and the same contrast ratio.
Common contrast mistakes with saturated accent colors
Saturated accent colors are the most common source of WCAG failures. A vivid lime like #c8ff00 has a relative luminance near 0.92, which means it passes contrast against black (1.6:1 against white, but 12.5:1 against black) but fails against white. Developers often choose accent colors for their visual impact without checking the contrast ratio against the background they will actually appear on. The fix is not to avoid saturated colors but to pair them with the correct background: use high-chroma colors on dark backgrounds and low-chroma, high-L colors on light backgrounds.
Using oklch() to find accessible variants of a brand color
When your brand color fails contrast on your target background, adjust its OKLCH L channel until the contrast passes. Reducing L from 0.96 to 0.75 on a lime green moves it from failing to passing AA against a white background, while keeping the same H and C preserves the brand hue identity. This approach is more reliable than adjusting HSL lightness because OKLCH L directly correlates with perceived brightness: a 0.1 L reduction produces a consistent perceived darkening regardless of the starting hue.5
Use this when choosing foreground and background color pairs for text, buttons, form fields, or any UI element where accessibility compliance is required, so you can check a color pair against WCAG contrast before committing to production CSS.
Dark text on light background check
#1a1a2e (text) on #f8f9fa (background)
14.5:1 — passes AAA for normal text
Well above all WCAG thresholds; suitable for body text at any size.
Accent color on white background check
#c8ff00 (text) on #ffffff (background)
1.6:1 — fails all WCAG levels
Lime on white is unreadable at all text sizes. Use a dark background instead.
- 1.
W3C, "Relative Luminance Definition," w3.org, accessed June 2026. https://www.w3.org/TR/WCAG21/relative-luminance.html
- 2.
W3C, "Understanding Success Criterion 1.4.3: Contrast (Minimum)," w3.org, June 2018. https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
- 3.
WebAIM, "Contrast and Color Accessibility," webaim.org, accessed September 2026. https://webaim.org/articles/contrast/
- 4.
Sara Soueidan, "A Guide to Designing Accessible, WCAG-Conformant Focus Indicators," sarasoueidan.com, August 2023. https://www.sarasoueidan.com/blog/focus-indicators/
- 5.
ColorUI Team, "OKLCH vs HSL: Why Modern Design Systems Pick OKLCH," colorui.io, May 2026. https://colorui.io/blog/oklch-vs-hsl-design-systems
WCAG 2.1 Level AA requires a contrast ratio of at least 4.5:1 for normal-sized text (below 18 point, or below 14 point if bold). Level AAA requires 7:1. Most web accessibility audits target AA compliance as the baseline.
Large text is defined as 18 point or larger (typically 24px at 96dpi), or 14 point bold or larger (typically 18.67px bold). Large text has a lower contrast threshold of 3:1 at AA and 4.5:1 at AAA.
No. WCAG contrast requirements apply to text, meaningful images of text, and user interface components. Purely decorative images, logos, and disabled controls are explicitly exempt.
WCAG 2.2 was published in October 2023 and is the current standard. It adds new criteria for mobile and cognitive accessibility, but the contrast ratio thresholds from WCAG 2.1 (Success Criteria 1.4.3 and 1.4.6) are unchanged in 2.2. Both versions require the same 4.5:1 minimum for normal text. CapyToolkit calculates contrast against WCAG 2.1 AA and AAA thresholds and shows both on the same panel so you can target whichever level your project requires.
Yes. The tool shows contrast ratios for black text and white text on your current color simultaneously. The panel with the higher ratio is the better pairing for any use case. If neither passes the threshold you need, the color itself may need to be adjusted.
How Auto-Fix finds a passing color
Most contrast tools stop at telling you that you failed. When a row here fails, the Fix
buttons go one step further and compute the nearest color that actually passes, keeping the
character of your palette intact. The search runs in OKLab, a perceptually uniform color
space, and adjusts only the lightness channel while holding hue and chroma constant, so a
failing brand blue becomes a lighter or darker blue rather than drifting toward purple the way
saturation tweaks in HSL often do.8
Some pairs can never pass
Under the hood, the tool searches lightness in both directions, toward black and toward white, and checks the true contrast ratio of the resulting screen color at every step. Whichever direction reaches your target with the smaller lightness change wins, which keeps the suggestion as close to your original color as the math allows. Some pairs simply cannot be fixed. Two mid-grays can never reach 7:1 no matter how far one of them moves, and in that case the button does not appear at all; the tool never offers a suggestion that would not pass.
Reading the color blindness preview
Roughly 1 in 12 men have some form of color vision deficiency, far more often than women, and most cases fall in the red-green range.9 The toggle above the preview re-renders your exact pair for protanopia, deuteranopia, and tritanopia, the three dichromatic forms in which one cone type is absent, by applying three fixed simulation matrices to the preview samples.10 Watching a red-on-green pairing collapse into two nearly identical browns makes a far more convincing argument for a palette change than any number can.
One thing the simulation deliberately does not do is change your results. The ratio is a property of the two colors themselves, so the ratio and every badge keep reporting the true pair while a filter is active.4 Treat the preview as a design instrument: it shows you why a numerically passing combination can still be hard to tell apart when the difference lives mostly in hue rather than in lightness.
Why a passing badge is not the finish line
A green badge means your pair clears a measurable bar, not that every reader will find it comfortable. Contrast requirements are minimums, and body text sitting exactly at 4.5:1 reads noticeably harder on a dim, uncalibrated laptop panel in a bright room than the same text at 7:1. For long-form reading, treating AAA as the target rather than the ceiling costs you very little in design freedom and buys real legibility for readers with low vision.
Color can't carry meaning alone
Contrast also cannot carry meaning by itself. Success criterion 1.4.1 requires that color is
never the only way information is conveyed, so a chart that distinguishes series purely by hue,
or a form that marks errors only by turning a border red, fails even when every pair in it
passes this checker.2 Pair the ratio with the color blindness
preview before you commit a palette: when two states remain distinguishable in all three
simulations and every row shows a passing badge, you have covered both the measurable and the
perceptual side of the problem.
What the requirements exempt
Not every piece of text owes the ratio anything. Success criterion 1.4.3 sets out its exceptions plainly: incidental text, which covers text on an inactive user interface component, pure decoration, text nobody can see, and text that is part of a picture with significant other visual content, has no contrast requirement, and text that is part of a logo or brand name has none either.3 The logic behind the exemptions is information transfer. The criterion protects text that carries meaning, and the exempted categories carry none on their own, so a logo rendered in brand colors at a failing ratio remains conformant, and a disabled button's grayed label is exempt for exactly as long as it stays disabled.
The non-text rule runs a parallel course. Under 1.4.11, inactive components sit outside the 3:1 requirement, and so does any component whose appearance the user agent itself determines rather than the author.5 The caution that follows the exemption list matters more than the list: exempt is not the same as harmless. A decorative headline that disappears into its backdrop fails no criterion, yet it still reads badly for visitors with low vision. Treat the exemptions as the scope rule they are, not as design permission, and the badge tiers stay honest.
WCAG 2.1 Contrast Thresholds
- Normal text AA / AAA 4.5:1 / 7:1
- Large text AA / AAA 3:1 / 4.5:1
- UI components (AA only) 3:1
Test your own pair above and check its per-tier badges against these thresholds.
- 1.
WebAIM, "The WebAIM Million: An annual accessibility analysis of the top 1,000,000 home pages," webaim.org, accessed July 2026. https://webaim.org/projects/million/
- 2.
W3C, "Web Content Accessibility Guidelines (WCAG) 2.1," w3.org, May 2025. https://www.w3.org/TR/WCAG21/
- 3.
W3C, "Understanding Success Criterion 1.4.3: Contrast (Minimum)," w3.org, June 2026. https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
- 4.
WebAIM, "Contrast and Color Accessibility," webaim.org, January 2021. https://webaim.org/articles/contrast/
- 5.
Eric Eggert, "In detail: 1.4.11 Non-Text Contrast (User Interface Components)," yatil.net, accessed September 2026. https://yatil.net/blog/non-text-contrast-in-detail-ui-components
- 6.
Wikipedia, "Web Content Accessibility Guidelines," en.wikipedia.org, accessed September 2026. https://en.wikipedia.org/wiki/Web_Content_Accessibility_Guidelines
- 7.
Accessibility.Build, "WCAG 2.1 vs 2.2: What Changed & How to Migrate," accessibility.build, July 2026. https://accessibility.build/guides/wcag-2-1-vs-2-2
- 8.
Björn Ottosson, "A perceptual color space for image processing," bottosson.github.io, December 2020. https://bottosson.github.io/posts/oklab/
- 9.
National Eye Institute, "Color Blindness," nei.nih.gov, November 2025. https://www.nei.nih.gov/eye-health-information/eye-conditions-and-diseases/color-blindness
- 10.
National Eye Institute, "Types of Color Vision Deficiency," nei.nih.gov, August 2023. https://www.nei.nih.gov/eye-health-information/eye-conditions-and-diseases/color-blindness/types-color-vision-deficiency