Color contrast calculator
Enter a text colour and a background colour as hex codes, and this tool calculates the contrast ratio between them.
Results
Enter your values to see the result.
About this tool
It shows whether the pair passes the accessibility levels AA and AAA for normal and large text and for interface parts. It helps you choose colours that people with low vision can read.
- How it is calculated
- relative luminance L = 0.2126 R + 0.7152 G + 0.0722 B, where each channel c (0 to 1) is converted with c ÷ 12.92 when c ≤ 0.03928 and ((c + 0.055) ÷ 1.055)^2.4 otherwise; contrast ratio = (L lighter + 0.05) ÷ (L darker + 0.05). WCAG 2.x asks for 4.5 (normal text, level AA), 3 (large text and interface parts), 7 (normal text, level AAA) and 4.5 (large text, level AAA). Large text is 24 px, or 18.66 px bold, and above.
- Worked example
- With Text colour (hex): #1a1a1a; Background colour (hex): #ffffff, the result is: Contrast ratio: 17.4 : 1; Text colour: #1a1a1a; Background colour: #ffffff; Luminance of the text colour: 0.01033; Luminance of the background: 1; AA, normal text (4.5): pass; AA, large text (3): pass; AAA, normal text (7): pass; AAA, large text (4.5): pass; Interface parts and graphics (3): pass.
- Good to know
- The contrast ratio uses the relative luminance of each colour, as set out in the Web Content Accessibility Guidelines 2.x. It needs 4.5 to 1 for normal text at level AA, 3 to 1 for large text and interface parts, and 7 to 1 for normal text at level AAA. Large text means 24 pixels, or 18.66 pixels in bold, and above.
Frequently asked questions
What contrast ratio do I need?
For normal text, at least 4.5 to 1 for level AA, and 7 to 1 for level AAA. Large text needs at least 3 to 1.
Is this the only thing that matters for readability?
No. Font size, font weight and spacing matter too, and a pair can pass the ratio and still be hard to read on a small screen.
Which colour formats can I enter?
Enter hex codes such as #1a1a1a. If you have another format, you can convert it first with the colour tools on this site.