Contrast Ratio Calculator

Calculate the WCAG contrast ratio between two HEX or RGB colors and check AA and AAA text thresholds instantly.

Color accessibility checker
Enter a lighter and darker color in HEX or RGB notation.

About the contrast ratio calculator

Color contrast describes the difference in relative luminance between a foreground and background. Adequate contrast helps people with low vision, color-vision differences, aging eyes, glare, or low-quality displays read and operate digital interfaces. This contrast ratio calculator converts two HEX or RGB colors to the relative-luminance values defined by the Web Content Accessibility Guidelines, then reports a ratio from 1:1 for identical luminance through 21:1 for black against white. The calculation does not simply compare raw red, green, and blue channel values. Each sRGB channel is normalized and linearized to account for display gamma. The linear red, green, and blue values receive luminance weights of 0.2126, 0.7152, and 0.0722 because human vision is most sensitive to green light. The final contrast ratio is the lighter luminance plus 0.05 divided by the darker luminance plus 0.05. This standard method produces consistent results regardless of which entered color is listed first. WCAG 2.x success criterion 1.4.3 requires at least 4.5:1 contrast for normal text at level AA and at least 3:1 for large text. Level AAA raises those thresholds to 7:1 and 4.5:1. Large text generally means at least 18 point regular text or 14 point bold text, approximately 24 CSS pixels or 18.66 CSS pixels respectively under common browser assumptions. User-interface components and meaningful graphical objects have separate requirements, commonly 3:1 against adjacent colors. Passing a ratio is important but does not guarantee an accessible design. Thin fonts, unusual typefaces, gradients, images, hover states, transparency, anti-aliasing, and changing backgrounds can alter effective readability. Placeholder text and disabled controls also deserve deliberate review even when a particular criterion treats them differently. Do not communicate status through color alone; pair colors with labels, icons, patterns, or other cues. Test focus indicators and every interactive state, not only the default screenshot. Enter six-digit HEX, three-digit HEX, or standard comma-separated RGB notation. The calculator validates channels from zero through 255 and evaluates the exact colors entered. If the result falls just below a threshold, adjust the foreground darker or the background lighter and calculate again. Automated contrast checking should be followed by keyboard testing, zoom and reflow checks, screen-reader review, and feedback from people with disabilities. Use this tool during design and implementation to catch basic color failures early, then verify the final rendered interface under realistic conditions.

Color contrast examples

These common color pairs show how small visual changes can cross an accessibility threshold.

Color pairContrast ratioWCAG result
#FFFFFF and #00000021.00:1Passes AA and AAA for normal and large text.
#FFFFFF and #7777774.48:1Passes large-text AA but narrowly fails normal-text AA.
#FFFFFF and #005FCC5.98:1Passes normal-text AA and large-text AAA, but not normal-text AAA.

How to check a color contrast ratio

  1. Copy the foreground and background colors from your design as HEX or RGB values.
  2. Enter the lighter color and darker color in the two fields.
  3. Select Calculate Contrast to compute the WCAG luminance ratio.
  4. Review each AA and AAA result for normal and large text.
  5. Adjust failing colors and retest every interactive state in the finished interface.

Contrast ratio calculator FAQ

What contrast ratio does normal text need?

WCAG 2.x level AA requires at least 4.5:1 for normal text. Level AAA requires at least 7:1, though project requirements should determine the target.

What counts as large text?

Large text is generally at least 18 point regular or 14 point bold. In typical CSS terms, those sizes are approximately 24 pixels and 18.66 pixels respectively.

Does it matter which color I enter first?

No, the formula always places the lighter luminance above the darker luminance. Reversing foreground and background therefore produces the same numeric contrast ratio.

Why does a visually different pair still fail?

Hue difference is not the same as luminance difference. Two saturated colors can look distinct while remaining too close in brightness for accessible text.

Does passing this check make a page accessible?

No, contrast is only one accessibility requirement. Keyboard use, semantics, focus, text alternatives, reflow, motion, and assistive-technology behavior must also be tested.