WCAG Color Contrast Checker

Check any foreground and background pair against WCAG 2.1 AA and AAA, convert HEX, RGB and HSL, and find a color that passes.

Free · Instant · Private
Quick answer: Contrast ratio = (Llighter + 0.05) / (Ldarker + 0.05), where L is WCAG relative luminance. WCAG 2.1 AA needs 4.5:1 for normal text and 3:1 for large text; AAA needs 7:1 and 4.5:1. Pure black on pure white is the maximum at 21:1. Enter two colors below for an instant, exact result.
Check a foreground and background color
Accepts #RGB, #RRGGBB, rgb(127, 86, 217) and hsl(258.8, 63.3%, 59.4%). Values update as you type.
Aa Bb Cc 123 — the quick brown fox Sample body text at normal size, shown in your exact colors.
Contrast ratio
17.4:1
AA normal text (4.5:1)
AA large text (3:1)
AAA normal text (7:1)
AAA large text (4.5:1)
UI components (3:1)
Foreground#1A1A1A
Background#FFFFFF
Suggested AA text color-

Common color pairs and their exact ratios

Every ratio below is computed live from the same WCAG formula used by the checker, so you can verify the numbers yourself.

TextBackgroundContrast ratioAA normalAAA normal
Convert one color between HEX, RGB and HSL
Paste any supported color notation. Alpha channels are not supported; use fully opaque colors for contrast testing.
HEX#7F56D9
RGBrgb(127, 86, 217)
HSLhsl(258.8, 63.3%, 59.4%)
Relative luminance0.1618
Color preview

Notation reference

NotationExampleRange
HEX (6 digits)#7F56D900 to FF per channel
HEX (3 digits)#F0AExpanded to #FF00AA
RGBrgb(127, 86, 217)0 to 255 per channel
HSLhsl(258.8, 63.3%, 59.4%)H 0 to 360, S and L 0 to 100%

What a Contrast Ratio Measures

A contrast ratio expresses how much lighter one color is than another on a scale from 1:1 (identical colors) to 21:1 (pure black against pure white). It is not a simple difference in brightness values. Because human vision is far more sensitive to green light than to blue light, the calculation weights the three sRGB channels differently. A pale yellow and a pale blue can look similarly bright while producing very different contrast ratios against the same background.

The Web Content Accessibility Guidelines (WCAG) 2.1, published by the W3C Web Accessibility Initiative, use this ratio as the measurable part of text legibility. Success Criterion 1.4.3 sets the Level AA minimum, and Success Criterion 1.4.6 sets the stricter Level AAA minimum. The checker above implements the normative formula exactly, without rounding intermediate values.

The Exact WCAG Formula

Relative luminance is computed from the sRGB channels in three steps:

  1. Divide each 8-bit channel by 255 to get a value c between 0 and 1.
  2. Linearize the channel: if c ≤ 0.03928, use c / 12.92; otherwise use ((c + 0.055) / 1.055)2.4.
  3. Combine them: L = 0.2126 R + 0.7152 G + 0.0722 B, where R, G and B are the linearized values.

Finally, contrast ratio = (Llighter + 0.05) / (Ldarker + 0.05). The 0.05 offset accounts for ambient flare and prevents a pure black background from producing a division by zero. This is why the scale tops out at 21:1 rather than infinity.

RequirementMinimum ratioApplies to
WCAG 2.1 AA, SC 1.4.34.5:1Normal text and images of text
WCAG 2.1 AA, SC 1.4.33:1Large text (at least 18 pt, or 14 pt bold)
WCAG 2.1 AAA, SC 1.4.67:1Normal text and images of text
WCAG 2.1 AAA, SC 1.4.64.5:1Large text
WCAG 2.1 AA, SC 1.4.113:1UI components, focus indicators and meaningful graphics

Incidental text, inactive controls, pure decoration and logos are exempt from the text contrast requirements under WCAG. Everything else that a user must read or identify should be checked.

HEX, RGB and HSL Explained

HEX stores each channel as two base-16 digits: #7F56D9 is red 0x7F = 127, green 0x56 = 86 and blue 0xD9 = 217. Three-digit shorthand duplicates each digit, so #F0A expands to #FF00AA. RGB is the same three numbers in decimal. HSL is a cylindrical transformation: hue is an angle on the color wheel, saturation is the distance from gray, and lightness is the midpoint between black and white. The converter above uses the standard HSL definition, so hsl(258.8, 63.3%, 59.4%) round-trips to #7F56D9.

HSL is useful for fixing contrast because changing lightness keeps the hue and saturation of a brand color. The suggested-color feature sweeps lightness from 0% to 100% at fixed hue and saturation and returns the closest value that reaches 4.5:1 against your background.

Worked Examples

Example 1: the maximum ratio

Black #000000 has relative luminance 0. White #FFFFFF has relative luminance 1. The ratio is (1 + 0.05) / (0 + 0.05) = 1.05 / 0.05 = 21:1. This is the highest contrast achievable in sRGB.

Example 2: a brand purple on white

#7F56D9 has relative luminance 0.161774. Against white (L = 1), the ratio is (1 + 0.05) / (0.161774 + 0.05) = 4.958:1. It passes AA for normal text and AA/AAA for large text, but it does not reach the 7:1 AAA normal-text threshold.

Example 3: the AA boundary for gray

#767676 on white gives 4.542:1, just above 4.5:1, so it passes AA normal text. #777777 on white gives 4.478:1 and fails. A single step in the 8-bit gray value can decide compliance, which is why measuring beats guessing.

Example 4: a failing pair

Pure red #FF0000 on white gives 3.999:1. It passes AA for large text and for non-text UI contrast, but fails AA for normal body text. Reducing the lightness of the red keeps the hue while raising the ratio above 4.5:1.

Common Mistakes

  • Using the difference of HEX or RGB values. Contrast is a ratio of linearized luminances, not a subtraction of channel numbers.
  • Skipping gamma linearization. Applying 0.2126 / 0.7152 / 0.0722 directly to sRGB values produces substantially wrong ratios.
  • Testing text over an image with a single background color. The text must pass against the lightest and darkest areas it actually overlaps, or sit on a solid overlay.
  • Ignoring opacity. Semi-transparent text composites with the background first; test the resulting opaque color. This tool deliberately accepts fully opaque colors only.
  • Checking only default states. Hover, focus, visited, disabled and placeholder styles need their own checks.
  • Assuming large text means visually big. WCAG uses a specific point-size definition, about 24 px regular or 18.66 px bold in CSS pixels.

Key Takeaways

  • AA needs 4.5:1 for normal text and 3:1 for large text; AAA needs 7:1 and 4.5:1.
  • The scale runs from 1:1 to 21:1, and 21:1 is only reachable with black on white.
  • Relative luminance weights green at 0.7152, red at 0.2126 and blue at 0.0722.
  • UI components and meaningful icons need 3:1 under SC 1.4.11.
  • Changing only the HSL lightness of a foreground color is the fastest way to fix a failing pair without losing brand hue.

Authoritative References

  • W3C, Web Content Accessibility Guidelines (WCAG) 2.1 - the normative definitions of SC 1.4.3, SC 1.4.6, SC 1.4.11 and relative luminance.
  • W3C WAI, Understanding SC 1.4.3 Contrast (Minimum) - explains the large-text threshold and the exemptions.
  • W3C, WCAG 2.1 definition of relative luminance - the 0.03928 cut-off, 12.92 divisor and 2.4 exponent used here.

Last updated: December 2, 2026 · All calculations are performed locally in your browser. No data is stored or transmitted.

Color Contrast Checker FAQ

What is a good contrast ratio for text?

WCAG 2.1 Level AA requires at least 4.5:1 for normal text and at least 3:1 for large text. Level AAA requires 7:1 for normal text and 4.5:1 for large text.

How is the WCAG contrast ratio calculated?

Contrast ratio = (Llighter + 0.05) / (Ldarker + 0.05), where L is relative luminance. Relative luminance is L = 0.2126 R + 0.7152 G + 0.0722 B after each sRGB channel has been linearized.

What is the maximum possible contrast ratio?

The maximum contrast ratio is 21:1, produced by pure black (#000000) against pure white (#FFFFFF). The minimum is 1:1, produced by any color against itself.

What counts as large text under WCAG?

WCAG defines large text as at least 18 point, or 14 point bold. In CSS pixels that is about 24 px for regular text and about 18.66 px for bold text.

Does WCAG contrast apply to buttons, icons and borders?

Yes. Success Criterion 1.4.11 Non-text Contrast requires at least 3:1 for user interface components and meaningful graphical objects such as icons, input borders and focus indicators.

How do I convert HEX to RGB?

Split the six HEX digits into three pairs and convert each pair from base 16 to base 10. For example, #7F56D9 becomes RGB(127, 86, 217). Three-digit HEX is expanded by doubling each digit, so #ABC becomes #AABBCC.

Why does green contribute more to luminance than blue?

The coefficients 0.2126, 0.7152 and 0.0722 reflect human photopic vision: the eye is most sensitive to green, less to red and least to blue. Two colors with the same numeric RGB distance can therefore have very different contrast ratios.

Is this contrast checker free and private?

Yes. It is free with no signup, and every calculation runs locally in your browser. No colors, text or design data are uploaded or stored.