First CHToolsFree web tools

FIRST CH TOOLS / Design / 03 CONTRAST CHECKER

WCAG Contrast Checker

Calculates the contrast ratio (WCAG 2.1) between text and background colors, with AA / AAA pass–fail results. The result is reflected in the URL so you can share it as-is (e.g. ?fg=333333&bg=ffffff).

Large text sample (24px bold)
This is normal body text. Use it to judge how readable this color pair is at body size (15px).
—
Contrast ratio
CriterionRequiredResult
AA — normal text4.5 : 1—
AA — large text (18pt / 14pt bold+)3 : 1—
AAA — normal text7 : 1—
AAA — large text4.5 : 1—
UI components & graphics (non-text)3 : 1—

How to Use

  1. Pick two colorsUse the color pickers or type HEX values (e.g. #333333) for text and background.
  2. Read the verdictThe contrast ratio and AA/AAA results update instantly, with a live preview of the pair.
  3. Share itThe result is written to the URL — copy it and send it to your team.

About This Tool

The contrast ratio is computed with the relative-luminance formula from WCAG 2.1, the international web accessibility standard. Body text on a typical website should meet "AA — normal text" (4.5:1 or higher). We run this check as a standard QA item before every site delivery.

A pair can clear the ratio and still fail people: colours told apart by hue alone — red against green — are indistinguishable for a predictable share of your audience (around 8% of men of northern European descent). The color blindness simulator shows the same two colours under protanopia, deuteranopia and tritanopia, and takes them straight from here.

How the Contrast Ratio Is Calculated

This tool follows the WCAG 2.1 definition, in this order:

  1. Divide each of R, G and B (0–255) by 255 to get a value c between 0 and 1.
  2. If c ≤ 0.03928, use c ÷ 12.92; otherwise use ((c + 0.055) ÷ 1.055)2.4 (this turns the screen value back into an amount of light).
  3. Relative luminance L = 0.2126 × R + 0.7152 × G + 0.0722 × B (green weighs most because the eye sees green as brightest).
  4. With L1 as the lighter colour and L2 as the darker one, contrast ratio = (L1 + 0.05) ÷ (L2 + 0.05).

The ratio runs from 1:1 (identical colours) to 21:1 (black and white), and swapping text and background gives the same value. For example, #767676 on white (#ffffff) is 4.54:1, which is why it is often used as the lightest grey that meets AA's 4.5:1 on a white background. The verdict uses the unrounded value, so a pair shown as "4.50" still fails if it falls short of the threshold.

From AI Agents

This tool's contrast-ratio and AA/AAA verdict logic is also available as the contrast_check tool in our MCP (Model Context Protocol) server @first-ch/tools-mcp, callable directly by AI agents with no browser needed. See Using These Tools from AI Agents for setup details.

Install

claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp

Example call

# example input passed to the agent
contrast_check(fg="333333", bg="ffffff")

Advertisement