Skip to content
FastTool

Color Contrast Checker

Check foreground and background colors against WCAG 2.2 AA and AAA rules, composite translucent rgba layers, and apply the nearest passing shade.

Runs in your browser. Nothing is uploaded.

Colors

Type #hex, rgb(), rgba(), hsl(), hsla() or oklch().

%

Solid #64748b, relative luminance 0.1706

Solid card or page color behind the text, icon or border.

Solid #f1f5f9, relative luminance 0.9085

Rendered foreground #64748b, rgb(100, 116, 139), oklch(0.554 0.041 257.4)
Background #f1f5f9, rgb(241, 245, 249), oklch(0.968 0.007 247.9)
Presets

Contrast check

Contrast ratio

Large text & UI only (3:1)

4.34:1

Unrounded: 4.3439:1 (0.16 below the 4.5:1 AA normal-text limit).

  • AA Normal text (4.5:1) Fails
    Needs 4.5:1 for body text under 24 px.
  • AA Large text (3:1) Passes
    Meets 3:1 at 24 px or 19 px bold.
  • AAA Normal text (7:1) Fails
    Needs 7:1 for AAA body text.
  • AAA Large text (4.5:1) Fails
    Needs 4.5:1 for AAA large text.
  • UI borders & icons (3:1) Passes
    Meets 3:1 for borders, icons and focus outlines.

Nearest passing foreground shade

WCAG AA normal text (4.5:1)

#627188 reaches 4.52:1 while keeping OKLCH hue and chroma.

WCAG AAA normal text (7.0:1)

#45546a reaches 7.02:1 while keeping OKLCH hue and chroma.

Live specimen and color-vision preview

Large heading at 24 px regular weight

Body copy at 16 px regular weight. Links, captions and table cells smaller than 24 px need 4.5:1 for AA and 7:1 for AAA.

19 px bold button Standalone icon (3:1)
Sample input with 2 px border (3:1)
  • 24 px regular = 18 pt large text (3:1 AA, 4.5:1 AAA)
  • 19 px bold = above 18.67 px (14 pt bold, 3:1 AA)
  • 16 px regular = normal text (4.5:1 AA, 7:1 AAA)
  • Border & icon = WCAG 2.2 SC 1.4.11 (3:1)

Color-blindness preview (Machado et al. 2009)

  • Protanopia (red-cone absent)

    Simulated contrast: 4.22:1

    #6c758c on #f4f5f9

  • Deuteranopia (green-cone absent)

    Simulated contrast: 4.42:1

    #68718a on #f3f4f9

  • Tritanopia (blue-cone absent)

    Simulated contrast: 4.32:1

    #59797c on #eff6f6

How to use

  1. Enter your foreground and background colors in #hex, rgb(), rgba(), hsl() or oklch(), or pick a preset.
  2. Set foreground opacity when testing semi-transparent captions, muted links or overlays, so the checker composites them over your background first.
  3. Read the contrast ratio and the five WCAG 2.2 checks for normal text, large text, and 3:1 input borders or icons.
  4. Click Apply AA or Apply AAA to switch to the nearest passing #RRGGBB shade with the same OKLCH hue and chroma.
  5. Inspect the live specimen and the color-blindness strip, then click Copy link to these colors to share your exact pair.

Worked example

Input

A muted slate link #64748b sits inside a light slate card #f1f5f9 at 100% opacity.

Working

Relative luminance is L = 0.1706 for #64748b and L = 0.9085 for #f1f5f9, giving (0.9085 + 0.05) / (0.1706 + 0.05) = 4.3439.

Result

At 4.34:1, the pair passes 3:1 for 24 px headings and borders, fails 4.5:1 AA body text, and fixes to #627188 (4.52:1).

On pure white #ffffff, that same #64748b link reaches 4.76:1 and passes AA. Moving it onto a #f1f5f9 card drops contrast to 4.34:1, which is 0.16 short of 4.5:1.

Clicking Apply AA (#627188) lowers OKLCH lightness slightly while keeping the slate hue and chroma intact. For AAA body copy, Apply AAA (#45546a) darkens lightness further to reach 7.02:1.

How it works

Relative luminance and the 0.04045 sRGB threshold

Each 8-bit sRGB channel is scaled to [0, 1] and converted to linear light using the exact IEC 61966-2-1 and WCAG 2.1+ piecewise curve:

C_lin = C / 12.92 if C ≤ 0.04045 C_lin = ((C + 0.055) / 1.055) ^ 2.4 if C > 0.04045 L = 0.2126 · R_lin + 0.7152 · G_lin + 0.0722 · B_lin

WCAG 2.0 originally printed 0.03928 by mistake. WCAG 2.1 errata and WCAG 2.2 corrected that constant to 0.04045, matching IEC 61966-2-1 where both pieces meet at 0.0031308.

Contrast ratio and threshold-safe rounding

From the lighter luminance L₁ and darker luminance L₂, W3C WCAG 2.2 defines the contrast ratio from 1:1 to 21:1:

Contrast ratio = (L₁ + 0.05) / (L₂ + 0.05)

Pass and fail badges always compare the unrounded ratio against 3.0, 4.5 and 7.0. A near-miss such as 4.496:1 displays as 4.49:1 rather than rounding up to 4.50:1, so the number and badge never disagree.

Alpha compositing, OKLCH shade solver and color vision

When foreground opacity α is below 100%, the checker blends foreground over background in sRGB with Porter-Duff source-over compositing before computing luminance:

C_out = α · C_fg + (1 − α) · C_bg

To find the nearest passing shade, the solver converts your color to Björn Ottosson’s OKLCH space and binary-searches lightness L while clamping chroma into sRGB. Every suggested #RRGGBB code is re-tested after 8-bit hex rounding to confirm its final contrast meets 3.0, 4.5 or 7.0.

The color-blindness strip transforms linear RGB channels with the full dichromacy matrices (severity 1.0) published by Machado, Oliveira and Fernandes (2009).

Sources

Sources checked 28 November 2026.

FAQ

What counts as large text in WCAG 2.2?

WCAG defines large text as 18 pt or 14 pt bold. Because CSS fixes 1 pt at 96/72 px (1.3333 px), that equals 24 px regular or 18.67 px bold (19 px in whole pixels).

Do form borders, icons and focus outlines need 4.5:1 contrast?

No. Under WCAG 2.2 Success Criterion 1.4.11, active control borders, custom focus outlines and standalone icons need at least 3:1 against adjacent colors. Disabled controls and brand logos are exempt.

Why does semi-transparent rgba() text pass on one card and fail on another?

Translucent text mixes with whatever color sits behind it. White text at 55% opacity reaches 6.07:1 over dark #0f172a, drops to 4.40:1 over #334155, and falls to 1.25:1 over light #cbd5e1.

Why does the Fix Shade button adjust OKLCH lightness instead of HSL?

Changing HSL lightness shifts perceived saturation and hue, especially in blues and yellows. Adjusting OKLCH lightness keeps perceived hue steady while reaching the exact WCAG ratio.

Read the full breakdown with worked examples in WCAG contrast rules for large text, icons, borders and translucent overlays.

Updated