Color Contrast Ratio Calculator
Free Color contrast ratio tool for art & design fundamentals. Enter values to see solutions, formulas, and educational explanations.
Calculator
Adjust values & calculateLarge Heading Text
Normal body text appears like this on the selected background color.
Small text and captions require highest contrast ratios.
Text Size Compliance
Formula
Where L1 is the relative luminance of the lighter color and L2 is the relative luminance of the darker color. Relative luminance L = 0.2126*R + 0.7152*G + 0.0722*B, where R, G, B are linearized sRGB values. The 0.05 offset accounts for ambient light.
Last reviewed: December 2025
Worked Examples
Example 1: Website Header Contrast Check
Example 2: Dark Mode Text Contrast
Background & Theory
The Color Contrast Ratio Calculator applies the following established principles and formulas. Educational measurement applies mathematical principles to quantify learning outcomes, track academic progress, and compare performance across students and institutions. Grade Point Average (GPA) is the central metric. In the standard four-point scale, letter grades are converted to grade points: A equals 4.0, B equals 3.0, C equals 2.0, D equals 1.0, and F equals 0. The GPA is then computed as the sum of (grade points multiplied by credit hours for each course) divided by total credit hours attempted. This weighted average ensures that high-credit courses exert proportionally greater influence on the final figure. Weighted GPA systems assign additional grade-point bonuses to honors, Advanced Placement, or International Baccalaureate courses, typically adding 0.5 to 1.0 points to acknowledge increased academic rigor. Unweighted GPA treats all courses equivalently regardless of difficulty. Percentile rank situates an individual score within a reference distribution: a student at the 75th percentile scored higher than 75 percent of the comparison group. Standardized tests use scaled scores and z-scores to normalize results across different test administrations. Standard deviation in test design quantifies how widely scores spread around the mean, informing item difficulty analysis and test reliability assessment. Bloom's Taxonomy, introduced in 1956, classifies cognitive learning into six hierarchical levels: remember, understand, apply, analyze, evaluate, and create. This framework guides curriculum design by ensuring assessments target higher-order thinking rather than only rote recall. Spaced repetition exploits the psychological spacing effect, whereby information reviewed at increasing intervals is retained far more efficiently than information reviewed in massed sessions. The SM-2 algorithm, developed by Piotr Wozniak in 1987, computes optimal review intervals using an ease factor updated after each recall attempt: I(n) = I(n-1) * EF, where the ease factor EF adjusts based on performance quality rated on a 0 to 5 scale. Flesch-Kincaid readability formulas estimate text difficulty. The Reading Ease score = 206.835 minus 1.015 times the average words per sentence minus 84.6 times the average syllables per word, where higher scores indicate easier text.
History
The history behind the Color Contrast Ratio Calculator traces back through the following developments. Formal mass education systems emerged in the early 19th century. Prussia established a compulsory state schooling system beginning around 1763 under Frederick the Great, though full enforcement and a structured curriculum took shape in the early 1800s. The Prussian model, emphasizing standardized instruction, teacher training, and compulsory attendance, became a template that the United States, Britain, Japan, and much of Europe adopted throughout the 19th century. Compulsory education laws spread across the industrializing world between roughly 1850 and 1900. Massachusetts passed the first such law in the United States in 1852. By the end of the century most developed nations had established free, publicly funded schooling systems with defined grade levels and curricula. The measurement of individual intelligence and academic aptitude arose at the turn of the 20th century. Alfred Binet, commissioned by the French government to identify students needing additional support, developed the first practical intelligence test in 1905 with Theodore Simon. Their scale introduced the concept of mental age and formed the basis for later intelligence quotient measurements. The Scholastic Aptitude Test, later the SAT, was introduced in the United States in 1926 by Carl Brigham, building on Army intelligence tests used during World War I. It became the dominant college admissions tool over the following decades, institutionalizing standardized testing in American secondary education. The second half of the 20th century brought accountability-driven reform. The Elementary and Secondary Education Act of 1965 tied federal funding to measured outcomes. The No Child Left Behind Act of 2001 required annual standardized testing in core subjects across all public schools and imposed consequences for persistent underperformance, intensifying debate about the validity and consequences of high-stakes testing. The 21st century introduced Massive Open Online Courses, or MOOCs, beginning with the Khan Academy in 2006 and expanding rapidly after Stanford's free online courses attracted hundreds of thousands of students in 2011. Digital learning platforms enabled spaced repetition software, adaptive assessments, and learning analytics to reach global audiences outside traditional institutions.
Frequently Asked Questions
Formula
Contrast Ratio = (L1 + 0.05) / (L2 + 0.05)
Where L1 is the relative luminance of the lighter color and L2 is the relative luminance of the darker color. Relative luminance L = 0.2126*R + 0.7152*G + 0.0722*B, where R, G, B are linearized sRGB values. The 0.05 offset accounts for ambient light.
Worked Examples
Example 1: Website Header Contrast Check
Problem: A website uses white text (#FFFFFF) on a blue background (#3B82F6). Does this meet WCAG AA requirements?
Solution: Foreground luminance: sRGB linearization of (255,255,255) = (1.0, 1.0, 1.0)\nRelative luminance = 0.2126 + 0.7152 + 0.0722 = 1.0\nBackground luminance: sRGB linearization of (59,130,246)\nR: ((59/255+0.055)/1.055)^2.4 = 0.0399\nG: ((130/255+0.055)/1.055)^2.4 = 0.2158\nB: ((246/255+0.055)/1.055)^2.4 = 0.9130\nRelative luminance = 0.2126(0.0399) + 0.7152(0.2158) + 0.0722(0.913) = 0.229\nContrast = (1.0+0.05)/(0.229+0.05) = 3.76:1
Result: Contrast ratio: 3.76:1 | AA Large Text: Pass | AA Normal Text: Fail (needs 4.5:1)
Example 2: Dark Mode Text Contrast
Problem: A dark mode design uses light gray text (#D1D5DB) on a dark background (#1F2937). Check all WCAG levels.
Solution: Foreground (#D1D5DB): R=209, G=213, B=219\nLinearized: R=0.637, G=0.659, B=0.694\nLuminance = 0.2126(0.637) + 0.7152(0.659) + 0.0722(0.694) = 0.657\nBackground (#1F2937): R=31, G=41, B=55\nLinearized: R=0.0102, G=0.0189, B=0.0361\nLuminance = 0.0178\nContrast = (0.657+0.05)/(0.0178+0.05) = 10.43:1
Result: Contrast ratio: 10.43:1 | All WCAG levels: Pass (AA, AAA, normal and large text)
Frequently Asked Questions
What is color contrast ratio and why is it important for accessibility?
Color contrast ratio is a numerical measurement of the difference in luminance (perceived brightness) between two colors, expressed as a ratio from 1:1 (no contrast, identical colors) to 21:1 (maximum contrast, black on white). It is critically important for web accessibility because approximately 1.3 billion people worldwide live with some form of visual impairment, including 300 million with color vision deficiency. The Web Content Accessibility Guidelines (WCAG) establish minimum contrast ratios to ensure text is readable by people with moderately low vision. Insufficient contrast makes content difficult or impossible to read, effectively excluding a significant portion of users from accessing information. Many countries now have legal requirements for digital accessibility.
What are the WCAG contrast ratio requirements?
WCAG 2.1 defines two conformance levels for contrast. Level AA (minimum) requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (defined as 18px regular or 14px bold and above). Level AAA (enhanced) requires 7:1 for normal text and 4.5:1 for large text. These requirements apply to text and images of text only; graphical elements and user interface components require a minimum 3:1 contrast ratio against adjacent colors under WCAG 2.1 Success Criterion 1.4.11. Logos and decorative text are exempt from contrast requirements. The upcoming WCAG 3.0 (currently in development) proposes a new APCA-based contrast model that may replace the current luminance ratio method.
How is the contrast ratio calculated mathematically?
The contrast ratio is calculated using the relative luminance of both colors. First, each sRGB color value (0-255) is converted to linear light by reversing the gamma curve: for values at or below 0.03928, divide by 12.92; for values above, apply the formula ((value + 0.055) / 1.055)^2.4. Then, relative luminance is calculated as L = 0.2126*R + 0.7152*G + 0.0722*B using the linearized values. Finally, the contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color luminance and L2 is the darker. The 0.05 offset accounts for ambient light reflections. This formula, defined in WCAG 2.1, ensures calculations align with how the human visual system perceives brightness differences.
What is the difference between WCAG 2.x contrast and APCA?
The WCAG 2.x contrast ratio formula treats foreground and background colors symmetrically, meaning white text on blue background and blue text on white background get the same ratio. However, human perception is not symmetric; light text on dark backgrounds appears differently than dark text on light backgrounds. The Advanced Perceptual Contrast Algorithm (APCA), proposed for WCAG 3.0, addresses this by incorporating polarity sensitivity (light-on-dark versus dark-on-light), font size and weight as variables in the contrast calculation, spatial frequency considerations, and better modeling of human visual perception. APCA produces directional contrast values (positive for dark-on-light, negative for light-on-dark) with different thresholds based on text size and weight, providing more nuanced and accurate accessibility guidance.
How does color blindness affect contrast perception?
Color blindness (color vision deficiency) affects approximately 8 percent of males and 0.5 percent of females of Northern European descent. The most common types are protanopia (red-blind), deuteranopia (green-blind), and tritanopia (blue-blind). Color blindness primarily affects the ability to distinguish between certain hues but generally does not affect luminance perception, which is why the WCAG contrast ratio (based on luminance) remains effective for most colorblind users. However, relying solely on color to convey information (like red for errors and green for success) creates problems because these colors may appear identical to red-green colorblind users. Best practice is to combine sufficient luminance contrast with additional visual cues such as icons, patterns, underlines, or text labels.
What tools and techniques help improve poor contrast ratios?
Several techniques can improve contrast ratios without dramatically changing design aesthetics. Darkening the background or lightening the foreground directly increases the luminance difference. Adding a semi-transparent overlay or text shadow behind text improves readability on variable backgrounds like images. Using a darker shade or tint of the same hue maintains brand consistency while improving accessibility. Increasing font size and weight reduces the required contrast ratio from 4.5:1 to 3:1 for large text. For designs with colored backgrounds, tools like Color Contrast Ratio Calculator help identify the exact adjustments needed to reach WCAG thresholds. Design systems should include pre-tested accessible color pairs, and automated testing tools like axe or Lighthouse can identify contrast failures during development.
References
Reviewed by Daniel Agrici, Founder & Lead Developer ยท Editorial policy