Colour contrast checker

Enter a text colour and a background colour as hex, rgb(), hsl() or a CSS name. The ratio, the WCAG 2.2 pass and fail results and a live preview update as you type, and when a pair fails you get the nearest colours that would pass. The whole check runs inside your browser.

Colour contrast checker

How it works

  1. Type or pick the text colour and the background colour. Hex, rgb(), hsl() and CSS colour names all work; there is no file to choose.
  2. Read the ratio and the five WCAG 2.2 checks: AA and AAA for normal and large text, and 3:1 for UI components and graphics.
  3. If a check fails, press Use next to a suggested colour, then copy the CSS.

Questions

Which rule does this check?

The WCAG 2.x contrast ratio (relative luminance, 1:1 to 21:1) as used by success criteria 1.4.3, 1.4.6 and 1.4.11 of WCAG 2.2. Normal text needs 4.5:1 for AA and 7:1 for AAA; large text (24px or more, or 18.66px bold) needs 3:1 for AA and 4.5:1 for AAA; UI components and graphics need 3:1. The ratio is shown truncated to two decimals, so 4.50 always means at least 4.5. APCA, the candidate model for WCAG 3, is a different measure and is not calculated here.

Can I use transparent colours?

No. The ratio is defined for opaque colours, and the tool refuses a colour with transparency instead of guessing. Enter the colour as it actually appears on the page, for example the composited result of a semi-transparent overlay.

What happens with values out of range?

An rgb() channel above 255 or below 0, or an hsl() percentage outside 0 to 100, is clamped to the nearest valid value, as browsers do, and the field tells you which colour was actually checked. Keywords such as currentcolor have no fixed value and are refused with an explanation, and transparent is refused as a fully transparent colour.

How are the suggested colours chosen?

The suggestion keeps the hue and the colourfulness (chroma) of your colour in the perceptual OKLCH space and moves only its lightness, in half-percent steps, until the pair reaches the required ratio; the smaller move of darker or lighter wins, and chroma is reduced only where the sRGB gamut forces it. Both the text and the background are offered. Nothing changes until you press Use. If no lightness of that hue can reach the ratio (for example 7:1 against a mid grey), the tool says so.

Does it pick colours from an image or build a palette?

Not on this page: it checks one text colour against one background colour and does not sample images. For a tonal scale and harmonies built around one colour, use the Colour palette generator from the same family; it is linked as the next step below.

Is anything uploaded?

No. The page loads a small script into your browser and every calculation runs on your device. You can check this yourself in the browser's network panel: after the page has loaded there are no upload requests. Closing the tab discards what you entered.

Do I need an account or to pay?

No. These basic tools are free, have no limits set by us and store nothing on our servers.

What does this page keep in my browser?

Nothing you open or type. While the tab is open, the tool pages keep a short list of the steps taken in it, in the tab's session storage: the step (page opened, started, succeeded, first success, used again or failed), the tool's name, the time, how many files were used and, for a failure, an error code; never a file name, the contents of a file or your text. It holds at most the latest 200 steps, and the browser deletes it when the tab closes. The page never sends it. Where a Report a problem button is shown, you can attach the last 20 steps to your report; nothing is attached unless you tick that box. In local storage the page keeps only choices you made: a Light or Dark theme until you choose System again, the language you picked with the EN / 中文 switch if it differs from your browser's language, and this tool in your recently used list if you switched that list on at the tools page.

Questions or problems

Found a problem or missing feature? Tell us. Please describe the steps; do not send confidential data.