CalcSeed

Color Contrast Checker

Enter a foreground and background hex color to measure their contrast ratio.

=
Quick answer: with the default inputs (#767676, #ffffff), the contrast ratio is 4.54. Change any input to update the result.
Contrast ratio
—

What this calculator measures

Enter any two hex colors and the calculator returns their WCAG contrast ratio as a single number, such as 4.54:1 for the default pair of #767676 text on a #ffffff background. It then grades the pair against the WCAG levels — AA normal text, AA large text and AAA normal text — so you can tell immediately whether a combination is publishable or needs another round of adjustment.

The contrast ratio formula

C=L1+0.05L2+0.05C = \frac{L_1 + 0.05}{L_2 + 0.05}

L1 and L2 are the relative luminances of the lighter and darker color, in that order — the ratio is always at least 1:1 regardless of which color is the foreground. Each luminance starts from the 8-bit RGB values and applies the sRGB transfer function defined in WCAG: a channel value c, scaled to 0–1, becomes c ÷ 12.92 when c ≤ 0.03928 and ((c + 0.055) ÷ 1.055)^2.4 otherwise. This gamma correction matches how human vision responds to light, which is why a mid-gray like #767676 ends up with a luminance near 0.18 rather than the naive 118 ÷ 255 ≈ 0.46.

The three corrected channels are combined with weights of 0.2126 for red, 0.7152 for green and 0.0722 for blue. Green dominates because the eye is most sensitive to it, which is why pure green (#00ff00) reaches a luminance of about 0.72 while pure blue (#0000ff) manages only about 0.07. The +0.05 added to both luminances prevents a divide-by-zero for pure black and fixes the scale: black on white lands at (1 + 0.05) ÷ 0.05 = 21:1, the maximum the formula can produce, while a color against itself yields 1:1.

Worked example: #767676 on #ffffff

The default foreground is a neutral gray, so all three channels equal 118 and contribute the same corrected value. Scaled, 118 ÷ 255 ≈ 0.4627, and the gamma branch gives (0.4627 + 0.055) ÷ 1.055 ≈ 0.4907, raised to the power 2.4 ≈ 0.1812. Since the channels match, the luminance is 0.1812, while white has a luminance of exactly 1. The ratio is therefore (1 + 0.05) ÷ (0.1812 + 0.05) = 1.05 ÷ 0.2312 ≈ 4.54:1, matching the calculator output.

Against the thresholds, 4.54 passes AA for normal text (4.5:1) and AA for large text (3:1) but fails AAA for normal text (7:1). The result panel reports exactly that: Pass, Pass, Fail. The pair is not arbitrary — #767676 is the darkest gray that still passes AA against white, which is why it keeps appearing in form placeholder and disabled-state guidance.

How to read the three grades

Treat the grades as gates, not suggestions. A Fail on AA normal means the color cannot serve as body text at any weight, though it may still pass as large text — the same 4.54:1 pair is valid for a 24 px heading. A Pass on AA but Fail on AAA marks text that works for general audiences yet falls short for strict government or education requirements, where 7:1 is sometimes mandated. Design systems commonly encode this by reserving one certified text color for AAA surfaces and a second, lighter one for AA-only headings.

Why #767676 passes and #777777 fails

One step lighter, #777777 (119 per channel) has a luminance of about 0.1845, giving a ratio of 1.05 ÷ 0.2345 ≈ 4.48 — just under the 4.5 cutoff. The gamma curve compresses the top of the range so heavily that a single RGB step near mid-gray swings the ratio by more than 0.05, while the same step near black is worth far less. When a design misses 4.5:1 by a hair, darkening the text usually fixes it faster than lightening the background.

WCAG thresholds at a glance

Content typeAA minimumAAA minimum
Body text (below 18pt)4.5:17:1
Large text (18pt+, or 14pt bold)3:14.5:1
UI components and graphics (WCAG 1.4.11)3:1—
Incidental or disabled elementsNo requirementNo requirement

Large text earns a relaxed 3:1 because bigger glyphs are easier to resolve. WCAG defines large as at least 18pt (about 24 px) at regular weight or 14pt (about 18.66 px) bold. The 3 / 4.5 / 7 ladder covers almost every decision: a 4.54:1 pair is publishable body text at AA but needs a larger size or a darker shade to reach AAA.

What moves the ratio

  • Lightness, overwhelmingly: luminance is mostly a lightness story, so shifting either color in HSL lightness moves the ratio fastest
  • Green content: green carries 71.52% of the luminance weight, so darkening a green-tinted text color raises the ratio more than the same shift in blue
  • Which color is lighter: the formula divides lighter by darker, so inverting a theme to light text on dark background runs the same math in reverse
  • Black and white anchors: any color against #000000 or #ffffff sits at the extreme ends of the 1–21 scale, making those two backgrounds the easiest to certify

Common mistakes when checking contrast

  • Testing only the body color and forgetting links, placeholders and focus outlines, which often inherit a lighter shade
  • Near-invisible pairs in reverse: white text on a #f8f8f8 card scores about 1.06:1 and is unreadable, yet ships in themed UIs more often than you would expect
  • Assuming a passing text ratio also covers icons — non-text contrast has its own 3:1 rule under WCAG 1.4.11
  • Rounding the ratio in documentation: 4.49:1 fails and 4.50:1 passes, so borderline pairs deserve a deliberate nudge rather than a rounding excuse

Another frequent slip is pasting an rgb() string or an 8-digit hex with an alpha channel. Both fail the parser and return an error instead of a ratio. Shorthand three-digit hex such as #fff is accepted and expands by doubling each digit, so #76a becomes #7766aa before the math runs.

Designing to a target level

Work in one direction at a time. If a pair fails AA at 4.2:1, darken the text color first, because text colors have fewer constraints than brand backgrounds; moving the background usually shifts the whole palette. Each check is instant, so iterate in small steps — 4.2, then 4.6, then done — rather than jumping straight to black and losing the intended tone.

For dark-mode themes the same math applies with the roles swapped. Light text on a #121212 background reaches high ratios easily, but muted secondary text often lands in the 3–4 range and fails AA for body copy. Check every text tier separately — primary, secondary, placeholder and disabled — because a theme that passes on headings can still fail on captions.

Frequently asked questions

What is a good contrast ratio?

4.5:1 is the common target for body text under AA. Large text can go as low as 3:1, and 7:1 is the stricter AAA level. The maximum possible ratio is 21:1, produced by black on white.

Does order of the colors matter?

No. The ratio uses the lighter and darker luminance regardless of which is the foreground, so swapping the two inputs always returns the same number.

What formats are accepted?

Three- or six-digit hex with an optional # prefix, such as #fff or #ffffff. Three-digit input is expanded by doubling each digit, so #76a becomes #7766aa.

Why does #767676 pass AA but #777777 fail?

The grays compute ratios of 4.54:1 and 4.48:1 respectively. The 4.5:1 cutoff falls between them, which makes #767676 the darkest AA-passing gray on a white background.

What counts as large text in WCAG?

At least 18pt (about 24 px) at regular weight, or 14pt (about 18.66 px) bold. Large text needs only 3:1 for AA and 4.5:1 for AAA.

What ratio does black text on white have?

Exactly 21:1 — the formula ceiling, since white’s luminance is 1 and black’s is 0, giving (1 + 0.05) ÷ 0.05. Pure white on pure black returns the same 21:1.

How is relative luminance calculated?

Each RGB channel is scaled to 0–1, gamma-corrected, then combined with weights of 0.2126 red, 0.7152 green and 0.0722 blue. Green dominates because human vision is most sensitive to it.

What contrast do icons and buttons need?

WCAG 1.4.11 sets 3:1 for meaningful non-text elements such as icons, input borders and focus states. That is checked separately from the text ratio.

Can I reach AAA without going black?

Yes. #595959 on white computes to almost exactly 7:1, the AAA threshold, so a dark gray keeps a softer look than pure black while still certifying.

Method and sources

Calculation basis

Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: November 18, 2026
Formula & data sources
  • WCAG 2.x contrast ratio and relative luminance definitions.

Cite this page

Reference formats
APA 7CalcSeed. (2026, November 18). Color Contrast Checker. https://calcseed.com/c/developer/color-contrast-checker/
MLA 9"Color Contrast Checker." CalcSeed, 18 Nov. 2026, calcseed.com/c/developer/color-contrast-checker/.
ChicagoCalcSeed. "Color Contrast Checker." Last modified November 18, 2026. https://calcseed.com/c/developer/color-contrast-checker/

Related calculators

More Developer calculators