# Color Contrast Checker

> Check text and background colours against WCAG 2.2 AA and AAA, and get the closest colour that passes.

- Page: https://codethatmoves.com/tools/graphics/contrast-checker/
- Site: Code That Moves
- Category: Icons and graphics
- Free, runs in the browser, nothing is uploaded
- Last checked: 2026-11-03

## What it does

- Contrast ratio from 1 to 21 for any two colours, truncated and not rounded up
- Five WCAG checks: AA and AAA for normal and large text, and 3:1 for UI parts and graphics
- Reads hex, rgb(), hsl(), oklch(), oklab(), color() and all 148 CSS colour names, with transparency over the background
- Pick either colour from anywhere on screen in Chrome and Edge (EyeDropper)
- Suggests the closest text or background colour that passes AA or AAA, keeping the OKLCH hue and chroma
- Shows the APCA Lc value for reference next to the WCAG result
- A live preview with normal text, large text, a button and an icon, and a link that keeps the pair

## How to use it

1. Type, paste or pick the text colour and the background colour. Any CSS colour format works, including oklch() from Tailwind v4.
2. Read the ratio and the five checks. Green means the pair meets that level.
3. If a check fails, use the closest text or background colour that passes, or copy the link to share the pair.

## What it checks and why

WCAG 2.2 sets minimum contrast between text and its background. Normal text needs 4.5 to 1 for level AA and 7 to 1 for AAA. Large text, which is 24 px or 19 px bold and up, needs 3 to 1 for AA and 4.5 to 1 for AAA. Icons, borders of form fields and focus rings need 3 to 1 against what is next to them (success criterion 1.4.11). The tool applies those numbers to the pair you give it.

The ratio comes from relative luminance, defined in WCAG: each colour channel is converted from sRGB to linear light and weighted by how bright the eye finds red, green and blue. The ratio is the lighter luminance plus 0.05, divided by the darker plus 0.05. A pair at 4.499 does not meet 4.5, so the tool truncates to two decimals and never rounds up.

When a pair fails, the tool looks for the nearest passing text colour and the nearest passing background. It keeps the OKLCH hue and chroma of your colour and moves only the lightness, so the result still looks like your brand colour, only darker or lighter. OKLCH is used because its lightness tracks how bright a colour looks, so the hue does not drift the way it can with HSL. A mid-tone background can leave no passing option in one direction, and the tool then tries the other.

## Specs and sources

- [WCAG 2.2: Contrast (Minimum), 1.4.3](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
- [WCAG 2.2: Contrast (Enhanced), 1.4.6](https://www.w3.org/WAI/WCAG22/Understanding/contrast-enhanced.html)
- [WCAG 2.2: Non-text Contrast, 1.4.11](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html)
- [WCAG 2.2: definition of relative luminance](https://www.w3.org/TR/WCAG22/#dfn-relative-luminance)

## Limits

- The WCAG ratio is a known weak model for dark backgrounds and thin fonts. Some pairs that pass look hard to read. APCA, a proposed replacement, is not part of WCAG 2.2, so its Lc value is shown for reference only and pass or fail follows WCAG.
- Colours outside sRGB, such as a vivid oklch() or display-p3 value, are brought into sRGB by lowering chroma before measuring. A semi-transparent background is measured laid over white.
- The screen picker uses the EyeDropper API, which Chrome and Edge support and Firefox and Safari do not; there the button is hidden.
- A transparent text colour is laid over the background before measuring. A text colour over an image or gradient needs a check at the worst spot.
- Large text is a size rule from WCAG, not a style, so check the real font size before you rely on the 3 to 1 level.
- Contrast is one part of readable text. Font weight, size, spacing and colour blindness matter too, and this tool does not simulate them.

## Questions

### What contrast ratio do I need for WCAG AA?

4.5 to 1 for normal text and 3 to 1 for large text and for UI parts such as icons and input borders. Large text is 24 px, or 19 px if bold, and bigger.

### What is the difference between AA and AAA contrast?

AAA asks for more: 7 to 1 for normal text and 4.5 to 1 for large text. Most laws and policies require AA. AAA is a higher goal, and WCAG itself says it is not possible for every kind of content.

### Does the contrast rule apply to logos and disabled buttons?

No. WCAG exempts logotypes, text that is part of an inactive control and pure decoration. Placeholder text in a field is not exempt, so it needs the same ratio as other text.

### Why does the ratio say 4.49 when other tools say 4.5?

The tool truncates instead of rounding. WCAG sets 4.5 as a minimum, so 4.499 does not pass, and rounding up would hide a real failure.

### Can I check oklch() colours, like the Tailwind v4 palette?

Yes. Paste oklch(), oklab() or color(display-p3 ...) values as they are. The tool converts them to sRGB, as a browser does on a standard screen, and measures the ratio from that.
