Contrast Ratio Calculator

Get the exact contrast ratio between two sRGB colors using the WCAG relative luminance formula. No sign-up, no server calls.

How to calculate a contrast ratio

  1. Enter foreground and background colors (hex, rgb(), or hsl()).
  2. Read the numeric WCAG ratio.
  3. Use the threshold badges to see AA/AAA for normal and large text.
  4. Swapping the two colors does not change the ratio.

FAQ

Using WCAG 2.x relative luminance: (L1 + 0.05) / (L2 + 0.05) where L1 is the lighter color.
Same engine. This route emphasizes the numeric ratio; the Contrast Checker emphasizes pass/fail badges.
Hex (#RRGGBB), rgb(), and hsl() syntax.
Black on white is the maximum contrast pair in WCAG relative luminance math, producing roughly 21:1. Higher numbers do not occur for sRGB.
No. Contrast ratio uses the lighter and darker luminance regardless of which color is text versus background.

Related tools