Color Contrast Ratio Checker

Calculate the exact WCAG contrast ratio with full step-by-step formula working.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

A color contrast ratio checker that goes further than a simple pass/fail — it shows the complete WCAG 2.x calculation line by line, so you understand exactly why a ratio is 4.54:1 rather than 4.5:1, and precisely how to adjust a color to cross a threshold. It is built for designers who want to see the math, developers who need an audit-ready report, and accessibility reviewers who have to justify every decision to a compliance team.

How it works

Every pixel color on a modern screen is encoded in sRGB, a color space that applies a gamma curve to compress bright values, because human vision is more sensitive to differences in dark tones than in bright ones. Before comparing two colors, the WCAG specification requires you to reverse that encoding and work in linear light, where values are proportional to actual photon counts. This is called sRGB linearization.

The linearization formula for each 8-bit channel c (in the range 0–255) is:

  • First normalize: c_norm = c / 255
  • If c_norm <= 0.03928: c_lin = c_norm / 12.92
  • Otherwise: c_lin = ((c_norm + 0.055) / 1.055) raised to the power 2.4

Once you have linear R, G, B values for a color, the relative luminance L is:

L = 0.2126 × R_lin + 0.7152 × G_lin + 0.0722 × B_lin

The green coefficient (0.7152) dominates because the eye is most sensitive to green light. Red contributes moderately, and blue contributes the least at 0.0722.

With luminance values L1 (lighter) and L2 (darker) computed for both colors, the contrast ratio is:

ratio = (L1 + 0.05) / (L2 + 0.05)

The constant 0.05 represents ambient reflected light and prevents division by zero when one color is pure black (L = 0).

Worked example

Take foreground #767676 (mid-grey) on background #ffffff (white).

  • White has R=G=B=255, so all three channels linearize to 1.0, and L(white) = 1.0000.
  • The grey channels are 118/255 ≈ 0.4627. The linearized value is ((0.4627 + 0.055) / 1.055)^2.4 ≈ 0.1812. Since all three channels are the same, L(grey) = 0.1812.
  • Lighter is white at 1.0000; darker is grey at 0.1812.
  • ratio = (1.0000 + 0.05) / (0.1812 + 0.05) = 1.05 / 0.2312 ≈ 4.54:1.

That just clears the AA normal text threshold of 4.5:1. Lighten the grey to #999999 and luminance rises to about 0.3185, making the ratio (1.05 / 0.3685) ≈ 2.85:1, which fails AA completely.

ForegroundBackgroundLuminance FGLuminance BGRatioAA normal
#000000#ffffff0.00001.000021.00:1Pass
#1a1a1a#ffffff0.01031.000017.40:1Pass
#767676#ffffff0.18121.00004.54:1Pass
#999999#ffffff0.31851.00002.85:1Fail
#ffd500#0000000.68850.000014.77:1Pass

Formula reference

The three coefficients (0.2126, 0.7152, 0.0722) are defined in the IEC 61966-2-1 sRGB standard and adopted by WCAG. They represent the CIE Y (luminance) component of each primary when converted from sRGB chromaticities. WCAG 2.0 uses the slightly older threshold of 0.03928 for the linearization branch (technically 0.04045 in IEC 61966-2-1 — the difference is negligible in practice); WCAG 3 is exploring the newer APCA model, but WCAG 2.x ratios remain the legal standard under WCAG 2.1 and EN 301 549.

The tool stores your colors in localStorage so you never lose work between sessions, and nothing is uploaded to any server.

Ad placeholder (rectangle)