Free tool · technology
Colour Contrast Checker
WCAG contrast ratio between two colours, with pass and fail at each level.
Colours
Enter any hex value or use the picker. Everything is calculated in your browser.
Result
Sample text
Normal body copy at 16px
12.87:1
- AA normal text (4.5:1): Pass
- AA large text (3:1): Pass
- AAA normal text (7:1): Pass
Embed this on your site
Free to embed. The attribution link stays with the widget, and the calculator keeps working exactly as it does here.
<iframe src="https://thedigitalstash.net/embed/color-contrast-checker" title="The Digital Stash calculator" width="100%" height="720" style="border:0;max-width:100%" loading="lazy"></iframe>
Understanding the Colour Contrast Checker
The Colour Contrast Checker is a tool designed to measure the readability of text against its background. By calculating the difference in relative luminance between two colours, it determines if a design meets the Web Content Accessibility Guidelines (WCAG) standards. These standards ensure that digital content remains accessible to users with visual impairments, including those with low vision or colour blindness.
The Method of Calculation
The tool follows the formula established by the World Wide Web Consortium (W3C). It first converts sRGB values into linearised sRGB values. This adjustment accounts for the non-linear way in which modern displays represent colour.
Once linearised, the relative luminance of each colour is calculated using the formula: L = 0.2126 * R + 0.7152 * G + 0.0722 * B
In this equation, the R, G, and B components are the linearised values of the red, green, and blue channels. The contrast ratio is then derived by taking the luminance of the lighter colour, adding 0.05, and dividing it by the luminance of the darker colour plus 0.05. This produces a ratio ranging from 1:1, representing no contrast, to 21:1, representing the maximum contrast between white and black.
Worked Example
Consider a scenario where a user selects a dark blue text colour and a light grey background colour.
- First, the tool identifies the relative luminance of the dark blue text. For this example, let us assume the luminance value is 0.15.
- Next, the tool identifies the relative luminance of the light grey background. We will assume a value of 0.85.
- To calculate the ratio, the tool adds 0.05 to both values.
- Text (darker): 0.15 + 0.05 = 0.20
- Background (lighter): 0.85 + 0.05 = 0.90
- The calculation becomes 0.90 divided by 0.20.
- The result is 4.5.
The final output for this example is a contrast ratio of 4.5:1.
Interpreting the Results
The WCAG guidelines define two primary levels of compliance: Level AA and Level AAA.
- Level AA: This is the standard requirement for most websites. It requires a contrast ratio of at least 4.5:1 for standard text and 3:1 for large-scale text or graphical objects. In our example above, the ratio of 4.5:1 would result in a "Pass" for standard text.
- Level AAA: This is the higher level of accessibility. It requires a contrast ratio of at least 7:1 for standard text and 4.5:1 for large-scale text. Using the previous example, a result of 4.5:1 would result in a "Fail" for standard text under Level AAA requirements.
A "Pass" indicates that the colour combination is likely to be readable by most users. A "Fail" indicates that the text does not provide enough contrast against the background, which may make the information difficult or impossible to read for people with vision conditions.
Assumptions and Limits
The tool operates on a few fundamental assumptions. It assumes that text is rendered on a standard monitor or mobile screen using the sRGB colour space. It also assumes that the text is plain, solid, and does not include complex textures, gradients, or shadows that might affect legibility.
There are important limits to this tool. Firstly, it calculates contrast based on the mathematical properties of colour, not the physical experience of reading. It cannot account for font weight, font size, or the specific typeface used. A thin, small font requires more contrast than a thick, bold font to achieve the same level of legibility, yet this tool treats all text character shapes as equal. It also does not factor in external conditions, such as screen glare or the specific settings of the user display.
Who This Tool is Not For
This tool is not intended for designers who require complex accessibility auditing. It does not perform a full site scan, nor does it check for accessibility issues beyond colour contrast, such as keyboard navigation, screen reader compatibility, or alt text.
Furthermore, this tool is not a substitute for user testing. While a design may pass the WCAG ratios, real-world accessibility often depends on the context of the content and the individual preferences of the user. If you are developing a professional product for an audience with specific medical requirements, you should supplement these automated checks with qualitative testing and feedback from users who rely on assistive technologies. This tool provides a baseline for compliance rather than a complete assessment of inclusive design.
More tools like this
Add Line Numbers
Number every line in a list, with aligned columns for code and checklists.
Run itAge Calculator
Exact age in years, months and days, plus days until the next birthday.
Run itAnagram Checker
Check whether two words or phrases use exactly the same letters.
Run it