Skip to main content
Preparing workspace

Color Contrast Checker

Free color contrast checker: get the WCAG 2.2 contrast ratio of two hex colors, see AA and AAA results for text and UI, and fix a failing pair.

Still loading. If the tool doesn’t appear, reload this page.

About this tool

WCAG Contrast Ratio Checker for Text and UI Colors

Check WCAG contrast for text and UI colors, preview transparency on any canvas and find a passing foreground shade.

The AltFTool Color Contrast Checker measures the WCAG 2.2 contrast ratio between a foreground and a background color and shows whether the pair passes AA and AAA for normal text, large text and non-text UI. Enter hex colors with or without transparency, set the canvas they sit on, and if the pair fails, apply a darker or lighter foreground that reaches your target. You can also audit one text color against up to 24 backgrounds, or a light and dark token map, and download the results.

How to use Color Contrast Checker

  1. Type a Foreground and a Background hex color, or use each swatch picker. The Canvas behind background field only matters when one of them uses alpha transparency.

  2. Read the Contrast ratio and the five Pass/Fail cards: AA normal text 4.5:1, AA large text 3:1, AAA normal 7:1, AAA large 4.5:1 and AA non-text 3:1.

  3. If the pair fails, choose a Suggestion target and press Apply darker or Apply lighter to swap in a passing foreground. Swap colors flips foreground and background.

  4. Press Copy CSS for the color and background declarations, or Copy report for a plain-text summary of the colors, ratio and every Pass/Fail line.

  5. To check several colors, open Palette audit and enter one Label, #hex background per line, then Download palette CSV; or paste a JSON token map in the Light and dark theme audit.

Why use Color Contrast Checker

  • All five WCAG checks at once

    See AA normal text (4.5:1), AA large text (3:1), AAA normal text (7:1), AAA large text (4.5:1) and AA non-text (3:1) for every pair.

  • No rounding up to a pass

    The ratio is shown rounded down to two decimals, and pass or fail uses the exact unrounded value, so 4.496:1 never reads as 4.50:1 next to an AA fail.

  • Transparency over a real canvas

    Enter 4- or 8-digit hex with alpha. The background is blended onto the canvas and the text onto that, and the preview uses the same layers as the calculation.

  • One-click passing shades

    Pick a target and the checker offers the closest darker and lighter foreground that reaches it, keeping your opacity. Apply one and the results update.

  • Palette and theme audits

    Check one foreground against a list of backgrounds and download a CSV, or audit light and dark token pairs and download the fixed token map as JSON.

How the WCAG contrast ratio is calculated

WCAG compares the relative luminance of two colors: how bright each one looks, from 0 for black to 1 for white. To get it, each sRGB channel is divided by 255 and linearized: values at or below 0.04045 are divided by 12.92, and higher values become ((c + 0.055) / 1.055) raised to the power 2.4. Luminance is then 0.2126 × R + 0.7152 × G + 0.0722 × B, which is why green affects perceived brightness far more than blue.

The contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color's luminance and L2 the darker one's. It runs from 1:1 (two identical colors) to 21:1 (black on white). The order does not matter for opaque colors, so swapping foreground and background gives the same ratio.

Two examples from this checker: #767676 grey on white measures 4.54:1 and passes AA for normal text, while the one step lighter #777777 measures 4.47:1 and fails it. The tool's starting pair, #111827 on white, measures 17.73:1. WCAG treats the threshold as a hard line, so the checker never rounds a ratio up to reach it.

AA vs AAA, and what counts as large text

Level AA is the level most laws, procurement rules and accessibility policies point to. It asks for 4.5:1 for normal text and 3:1 for large text. Level AAA is stricter, at 7:1 and 4.5:1, and is usually applied to long reading content or where users are known to have low vision.

Large text means at least 18 point regular or 14 point bold. In CSS pixels that is about 24 px regular or 18.66 px bold. Size alone is the rule: a 20 px heading at normal weight is still normal text and needs 4.5:1 for AA. The checker shows the normal and large results side by side, so read the row that matches the size and weight of your text.

Non-text contrast for icons, borders and focus rings

WCAG 1.4.11 asks for 3:1 for the parts of the interface people need to see to use it: icons without a text label, the border that shows where an input is, the checked state of a checkbox, a focus indicator, and the lines or segments of a chart. The ratio is measured against the adjacent color, not always the page background.

To check one, enter the icon or border color as the foreground and the color right next to it as the background, then read the AA non-text card. A light grey input border on white often fails here even when the input text passes.

Why transparent colors need a canvas color

A color with alpha, such as #0000008a or an 8-digit design token, has no single contrast ratio on its own: what you see depends on what shows through it. The checker blends the background onto the opaque canvas you set, then blends the foreground onto that result, and measures the colors that would actually appear on screen. The preview is drawn with the same layers.

For example, #00000080 (black at 50% opacity) on a white background over a white canvas measures 4.00:1. Change the canvas to a dark page color and a translucent background changes the result, so set the canvas to the surface your component really sits on. With translucent colors, swapping foreground and background can also change the ratio.

How to fix a pair that fails

Choose the Suggestion target you need: AA normal text, AA large text or non-text, or AAA normal text. When the pair fails, the checker mixes the foreground step by step toward black for a darker option and toward white for a lighter option, keeps the opacity you set, and shows the first shade on each path that passes. The option that needs the smaller change is listed first.

If no suggestion appears, neither black nor white text at that opacity reaches the target on your background. Make the foreground more opaque, change the background, or choose a lower target if your text is large. For a whole palette, open Palette audit; for design tokens, the theme audit suggests a passing foreground for each failing pair and lets you apply it before downloading the token map.

WCAG 2.2 contrast vs APCA and WCAG 3

This checker uses the WCAG 2.x contrast formula, the one WCAG 2.0, 2.1 and 2.2 share, and the one current accessibility audits and conformance claims are measured against. WCAG 2.2 uses 0.04045 as the sRGB linearization breakpoint, which the tool follows.

APCA (the Accessible Perceptual Contrast Algorithm) is a different method that has been explored for WCAG 3. WCAG 3 is still a draft and is not a standard you can claim conformance to, so the checker does not show APCA scores. A pair that passes here meets the WCAG 2.2 contrast criteria; it can still be worth testing real text sizes and weights with users.

WCAG 2.2 contrast requirements

The minimum contrast ratios this checker tests, and what each one applies to.
Check in the toolWCAG success criterionMinimum ratioApplies to
AA normal text1.4.3 Contrast (Minimum), Level AA4.5:1Body text and any text smaller than the large-text size
AA large text1.4.3 Contrast (Minimum), Level AA3:1Text at least 18 pt (24 px), or 14 pt (about 18.66 px) and bold
AAA normal text1.4.6 Contrast (Enhanced), Level AAA7:1Body text when you aim for the enhanced level
AAA large text1.4.6 Contrast (Enhanced), Level AAA4.5:1Large text when you aim for the enhanced level
AA non-text1.4.11 Non-text Contrast, Level AA3:1Icons, chart parts, input borders, focus indicators and control states, against adjacent colors

Logos, purely decorative text and inactive (disabled) controls are exempt from the text criteria. Non-text contrast has no AAA level.

Common use cases

  • Check body text, links and button labels against white, a brand color or a dark theme surface before a design review.
  • Confirm that an icon, input border or focus ring reaches 3:1 against the color next to it (WCAG 1.4.11 non-text contrast).
  • Measure semi-transparent text or an overlay over the exact canvas it will appear on, such as a card on a grey page.
  • Test one text color against up to 24 palette backgrounds and send the CSV to the team that owns the palette.
  • Audit the same foreground/background token pairs in light and dark mode, fix a failing dark-mode token, and export the updated token map.

Frequently asked questions

What contrast ratio do I need to pass WCAG?

For Level AA you need at least 4.5:1 for normal text, 3:1 for large text and 3:1 for meaningful icons, borders and focus indicators. For Level AAA you need 7:1 for normal text and 4.5:1 for large text. The checker shows all five results for every pair.

Link to answer
Is this checker based on WCAG 2.2 or WCAG 3?

WCAG 2.2. It uses the WCAG 2.x relative luminance formula with the 0.04045 breakpoint and the (L1 + 0.05) / (L2 + 0.05) ratio. It does not calculate APCA, which belongs to the WCAG 3 draft.

Link to answer
Why does a ratio of 4.49:1 fail AA?

Because WCAG thresholds are exact. The checker compares the unrounded ratio with 4.5, and it rounds the displayed value down, so a pair at 4.496:1 shows 4.49:1 and fails rather than appearing as 4.50:1.

Link to answer
What color formats can I enter?

Hex only: 3, 4, 6 or 8 digits, with or without the #, such as #fff, #1663d9 or #1663d980. The 4- and 8-digit forms include alpha. Each field also has a color picker for opaque colors. The canvas must be an opaque hex color.

Link to answer
How do transparent colors affect contrast?

The background is blended onto the canvas, then the foreground is blended onto that, and the ratio is measured on the result. Changing the canvas can change the result, and with translucent colors swapping foreground and background can change it too.

Link to answer
Can the checker suggest a color that passes?

Yes. Choose a Suggestion target and, when the pair fails, it offers the nearest darker and lighter foreground that meets it, keeping your opacity. If neither appears, change the background, make the foreground more opaque or pick a lower target.

Link to answer
Can I check one text color against many backgrounds?

Yes. Open Palette audit and enter up to 24 backgrounds, one per line, with an optional label such as "Card, #fff". It uses your current foreground, canvas and target, and Download palette CSV saves the ratio and result for each row.

Link to answer
Are my colors sent anywhere?

No. The checker itself makes no network requests: the ratio, suggestions and audits are calculated in your browser, and the CSV and JSON downloads are created on your device.

Link to answer