Color Converter & WCAG Contrast Checker

Enter a text color and a background color to convert both between HEX, RGB and HSL and to see their WCAG 2 contrast ratio, with a live preview and a clear pass or fail for AA and AAA. If a pair fails, the tool suggests the closest text color that passes. Everything runs in your browser.

Processed locally in your browser. Your data is not uploaded to our servers.

Use HEX (#336699 or #369), rgb(51, 102, 153), hsl(210, 50%, 40%) or a color name such as navy. Transparency is understood.

Result

Examples

Reference ratios you can check against other tools (text on white):

Text colorContrast on whiteAA normal text
#00000021.00 : 1Pass
#5959597.00 : 1Pass
#7676764.54 : 1Pass
#7777774.48 : 1Fail
#9494943.03 : 1Fail

Formula & Methodology

Each channel is converted from sRGB to linear light, and relative luminance is L = 0.2126 R + 0.7152 G + 0.0722 B. The contrast ratio is (L1 + 0.05) รท (L2 + 0.05) with L1 the lighter color, from 1 : 1 (identical) to 21 : 1 (black on white). WCAG 2 asks for 4.5 : 1 for normal text and 3 : 1 for large text at level AA, and 7 : 1 and 4.5 : 1 at level AAA. Interface components and graphics need 3 : 1.

L = 0.2126 R + 0.7152 G + 0.0722 BCR = (L1 + 0.05) รท (L2 + 0.05)

Ratios are shown to two decimals, but pass or fail uses the exact value: 4.499 : 1 never counts as 4.5 : 1.

Notes and limitations

  • This is the WCAG 2.x contrast method. It does not predict readability for every person, and newer methods such as APCA are not covered.
  • Large text means at least 24 CSS pixels, or 18.66 pixels (14 pt) in bold.
  • Contrast depends on the final rendering: anti-aliasing, font weight, images behind text and gradients are not measured.
  • Supported formats: HEX (3, 4, 6, 8 digits), rgb()/rgba(), hsl()/hsla() and a few basic color names. Other CSS color spaces (lab, oklch, color()) are not supported.
  • A translucent text color is measured after blending with the background; a translucent background is blended with white.

How to Use

  1. Type the text color and the background color, or use the color pickers.
  2. Read the converted values and copy the format you need.
  3. Check the contrast ratio and the pass or fail result for each requirement.
  4. If the pair fails, try the suggested text color or adjust a color.

Frequently Asked Questions

What contrast ratio do I need?

For WCAG 2 level AA, normal text needs at least 4.5 : 1 and large text at least 3 : 1. Level AAA asks for 7 : 1 and 4.5 : 1. Interface controls and meaningful graphics need 3 : 1 against their surroundings.

What counts as large text?

Text of at least 24 CSS pixels, or at least about 18.7 pixels (14 point) when it is bold. Everything smaller is normal text.

Which color formats can I enter?

HEX with 3, 4, 6 or 8 digits, rgb() and rgba(), hsl() and hsla(), and a set of basic color names such as red, navy or rebeccapurple. Both comma and space syntax work.

Why does 4.5 : 1 sometimes show as failing?

The ratio shown is cut to two decimals, but the test uses the exact value. A ratio of 4.4999 would be written 4.49, because it does not meet the 4.5 : 1 requirement.

Is anything sent to a server?

No. Conversions and contrast checks run in your browser and nothing you enter is uploaded or sent to analytics.

Last updated: