Contrast Ratio Calculator

Calculate the contrast ratio between any two colours using the WCAG 2.1 relative luminance formula. Enter hex colour codes or use the colour pickers to check whether your colour pairs meet accessibility standards for text, large headings, and interface components.

Calculate.co.nz is proud to be partnered with Premium Homes, a recognised leader in eco-friendly, sustainable, and energy-efficient homebuilding. With a dedicated team and award-winning experience, they create homes that prioritise health, comfort, and long-term performance. Their founders, Andrew and Kelly, set out to raise the standard of residential construction in New Zealand by combining practical building expertise with a clear commitment to doing things better for homeowners.
Calculate.co.nz partner: Premium Homes
WCAG 2.1 formula  W3C Web Content Accessibility Guidelines 2.1 (ISO/IEC 40500:2012). WCAG 3.0 draft does not yet replace this standard.

1. Foreground Colour (Text)

Sample Text

2. Background Colour

Sample Text
Sample Text on This Background

Contrast Ratio Result

Contrast Ratio
-
Higher is better
Foreground Luminance
-
Relative (0 to 1)
Background Luminance
-
Relative (0 to 1)
Overall Grade
-
Best WCAG level met

WCAG 2.1 Accessibility Check

AA
Normal text
Minimum 4.5:1
-
AA
Large text (18pt+)
Minimum 3:1
-
AA
UI components
Minimum 3:1
-
AAA
Normal text
Minimum 7:1
-
AAA
Large text (18pt+)
Minimum 4.5:1
-
Summary
Overall rating
Best level achieved
-

Luminance Breakdown

Foreground colour-
Foreground RGB-
Foreground linearised R-
Foreground linearised G-
Foreground linearised B-
Foreground luminance (L1)-

Calculation Steps

Background colour-
Background RGB-
Background luminance (L2)-
Lighter luminance (L1)-
Darker luminance (L2)-
Contrast ratio formula-
Result: Enter two colours above to check their contrast ratio.

What Is Contrast Ratio?

Contrast ratio is a measure of the visual difference in luminance between two colours, typically a foreground (text) and background colour. It is expressed as a ratio such as 4.5:1 or 21:1. A ratio of 1:1 means the colours are identical with no contrast. A ratio of 21:1 is the maximum possible contrast, achieved between pure white and pure black.

High contrast between text and background is essential for readability, particularly for people with low vision, colour blindness, or who read in challenging lighting conditions. The Web Content Accessibility Guidelines (WCAG) published by the W3C set minimum contrast requirements for digital content. New Zealand's government web accessibility standard (Web Accessibility Standard 1.1) requires conformance with WCAG 2.1 Level AA.

The WCAG Relative Luminance Formula

WCAG 2.1 defines relative luminance as the normalised luminance of a colour, ranging from 0 (pure black) to 1 (pure white). The calculation steps are:

  1. Divide each RGB channel value (0 to 255) by 255 to get a value between 0 and 1.
  2. Linearise each channel: if the channel value is 0.04045 or below, divide by 12.92. If above 0.04045, apply: ((value + 0.055) / 1.055) ^ 2.4
  3. Calculate relative luminance: L = 0.2126 x Rlin + 0.7152 x Glin + 0.0722 x Blin
  4. Determine contrast ratio: CR = (Llighter + 0.05) / (Ldarker + 0.05)

The 0.05 offset in the contrast ratio formula represents the luminance of the display surface, accounting for the fact that even a "black" screen has some minimum light output.

WCAG Accessibility Requirements

Content TypeWCAG AA (minimum)WCAG AAA (enhanced)
Normal body text (below 18pt or 14pt bold)4.5:17:1
Large text (18pt or larger, or 14pt bold or larger)3:14.5:1
UI components and graphical objects3:1Not defined
Decorative text or logosNo requirementNo requirement
Disabled text or componentsNo requirementNo requirement

Note: 18pt is approximately 24px at standard screen resolution. 14pt bold is approximately 18.67px bold.

Worked Example

Using white (#ffffff) as the foreground (text colour) and black (#000000) as the background:

This 21:1 ratio is the maximum achievable and represents the default output of this calculator. Most designs aim for at least 4.5:1 for body text, which allows more colour freedom while maintaining accessibility.

Practical Tips for Accessible Colour Design

Related Calculators

Sources and method: W3C Web Content Accessibility Guidelines (WCAG) 2.1, Success Criterion 1.4.3 (Contrast Minimum) and 1.4.6 (Contrast Enhanced) (w3.org/TR/WCAG21). W3C WCAG 2.x relative luminance definition and contrast ratio formula (w3.org/TR/WCAG21/#dfn-relative-luminance). New Zealand Government Web Accessibility Standard 1.1 (digital.govt.nz).

This calculator implements the WCAG 2.1 relative luminance and contrast ratio formula exactly as defined by the W3C. Results apply to standard sRGB colour space. Colour inputs must be valid 6-digit hex codes. The calculator does not account for colour blindness, font rendering differences, or non-standard display profiles.

If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.

Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.

Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.

All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.

Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.

Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.

Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.

All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.

About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use

Reviewed and maintained. Last reviewed 2026-07-02 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.

© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.