splicedesign / culture / practice
← All tools

Accessibility tool

Contrast Checker

Enter any two colours to get their exact contrast ratio, the WCAG 2.1 verdict for every text size, and the nearest colour that would pass.

Inputs

Result

— :1 contrast ratio

Large heading sample

Body copy sample — the quick brown fox jumps over the lazy dog. This block uses the exact pair you entered.

How to use it

  1. Pick the text colour and the background colour with the colour pickers, or paste hex values directly.
  2. Read the ratio and the pass/fail chips for normal text, large text, UI components and AAA.
  3. Adjust the slider-free way: use “Swap colours” to test the reverse combination.
  4. If the pair fails, take the suggested fixed colour from the panel — it is the closest shade to your original that reaches the target.

How it is calculated

The tool implements the WCAG 2.1 relative luminance definition. Each 8-bit channel is normalised, linearised, then weighted by human sensitivity to green.

C = ch / 255
if C ≤ 0.03928:  c = C / 12.92
else:            c = ((C + 0.055) / 1.055) ^ 2.4

L = 0.2126·R + 0.7152·G + 0.0722·B          (relative luminance)

ratio = (L_lighter + 0.05) / (L_darker + 0.05)

Thresholds come straight from WCAG 2.1 success criteria: 1.4.3 Contrast (Minimum) requires 4.5:1 for normal text and 3:1 for large text — defined as 18.66px bold or 24px regular and above — while SC 1.4.11 requires 3:1 for interface components and graphical objects. AAA (SC 1.4.6) asks for 7:1, or 4.5:1 for large text.

The fix suggestion keeps the hue and saturation of your original colour and walk-tests its lightness in 0.5% steps until the ratio meets your target, so the suggested colour stays recognisably “yours”.

Worked example

Take #767676 body text on a #ffffff background. The grey linearises to a relative luminance of about 0.1845, white is 1.0, giving:

(1.0 + 0.05) / (0.1845 + 0.05) = 4.48:1

That is a hair below AA for normal text, which is why you often see #757575 recommended instead — it lands at 4.6:1. Try both values in the tool above; small hex changes matter here.

Where this works, and where it does not

Use it for anything rendered on a screen with known colours: brand palettes, button states, charts, dark mode tokens. It is exact maths, so it will agree with any conformant checker.

It does not cover contrast over images or gradients, transparency blending, text on video, or the needs of people whose requirements differ from those modelled by the formula. It also says nothing about font choice, size relationships or reading comfort — those are judgement calls covered in the guides.

Reference: W3C, Web Content Accessibility Guidelines (WCAG) 2.1, success criteria 1.4.3, 1.4.6 and 1.4.11.