How to use the Color Contrast Checker
- Enter the text (foreground) color on the left and the background color on the right: #hex, rgb(), hsl(), oklch() or a CSS name.
- Read the contrast ratio and the AA and AAA results for normal text, large text and UI components, and check the preview.
- If a level fails, use the suggested nearest text color that passes.
Questions
Is my data uploaded anywhere?
No. The tool runs entirely in your browser. Nothing you paste or drop is sent to a server, logged or stored, so it's safe for API responses, config files and other private data.
What contrast ratio do I need?
WCAG 2 level AA needs 4.5:1 for normal text and 3:1 for large text and UI components such as icons and input borders. Level AAA needs 7:1 for normal text and 4.5:1 for large text.
What counts as large text?
Text of at least 18 points (24 CSS pixels), or at least 14 points (about 18.66 pixels) when bold.
How is the contrast ratio calculated?
From the relative luminance of the two colors: (lighter + 0.05) / (darker + 0.05), from 1:1 for identical colors to 21:1 for black on white. The ratio is cut to two decimals, so 4.499 shows as 4.49 and fails AA.
What about transparent colors?
A translucent text color is blended over the background first. A translucent background is blended over white.
Can I check contrast in VS Code?
Yes. Nifty Colors shows a swatch next to every color in your code, and hovering one shows its WCAG contrast against white, black and the nearest other color.