Skip to main content

Color Converter & WCAG Contrast Checker

Convert HEX, RGB, HSL, OKLCH, and CSS names while checking WCAG 2.1 AA and AAA contrast ratios at full precision with nearest passing shade suggestions.

By Lasita Engineering TeamLast reviewed: Examples verified by hand & automated test suite

WCAG 2.1 Contrast Ratios at a Glance

Strong text and border contrast makes interfaces readable on phones in sunlight and for people with low vision. WCAG 2.1 checks relative luminance contrast using (L1 + 0.05) / (L2 + 0.05):

  • Normal body text (< 18pt / 24px): AA requires 4.5 : 1, AAA requires 7.0 : 1.
  • Large text (≥ 18pt or ≥ 14pt bold): AA requires 3.0 : 1, AAA requires 4.5 : 1.
  • UI borders, icons & focus rings: AA requires 3.0 : 1.

Why Full Precision Matters

A common bug in contrast widgets is rounding 4.4997 (for example, #5a2309 on #23abb4) up to 4.50 and showing a false "PASS" badge. Automated audits evaluate the exact unrounded ratio. This tool always compares full floating-point precision, displays 4 floored decimal digits, and clears previous scores immediately whenever either color input is invalid.

Limits

OKLCH inputs outside the standard sRGB gamut are clamped channel-by-channel to sRGB for HEX/RGB output and WCAG 2.1 relative luminance calculation. Translucent foreground colors are composited over the background color before computing luminance.

Frequently Asked Questions

Why does a 4.4997:1 contrast ratio fail WCAG AA even if some tools show 4.50:1?

WCAG 2.1 requires a contrast ratio of at least 4.5:1 for normal text without rounding up. A pair like #5a2309 on #23abb4 measures 4.4997:1, which is strictly below 4.5:1. This checker evaluates full floating-point precision, floors the 2-decimal headline, and displays 4 decimals so failing pairs never print 4.500.

Which CSS color formats and transparency notations are supported?

You can enter 3/4/6/8-digit HEX (#fff, #ffffff80), rgb()/rgba(), CSS Color 4 slash syntax (rgb(0 0 0 / 50%)), hsl()/hsla(), hwb(), lab(), lch(), oklab(), OKLCH (including leading-dot decimals like oklch(.6 .2 29)), and all 148 standard CSS named colors such as red or rebeccapurple.

Why are nearest passing color suggestions calculated in OKLCH?

OKLCH separates perceptual lightness (L) from hue (H) and chroma (C). Adjusting only lightness in OKLCH keeps your brand hue consistent while stepping smoothly to the closest sRGB color that strictly passes 4.5:1 (AA) or 7.0:1 (AAA).

Read the full engineering reference: Practical Reference for Everyday Developer Data: JSON, Regex, Unix Timestamps, Base64 & WCAG Contrast →