Gathering detailed insights and metrics for color-contrast-checker
Gathering detailed insights and metrics for color-contrast-checker
Gathering detailed insights and metrics for color-contrast-checker
Gathering detailed insights and metrics for color-contrast-checker
a11y-color-contrast-checker
A lightweight utility for checking color contrast ratios between foreground and background colors in the DOM, ensuring accessibility compliance with WCAG guidelines. Perfect for web developers and designers aiming to create inclusive digital experiences
wcag-color-contrast-checker
A simple color contrast checker based on the WCAG recommendations.
is-contrast-checker
Color palette combination contrast tester
the-simplest-color-checker
A powerful, dependency-free color manipulation library
An accessibility checker tool for validating the color contrast based on WCAG 2.0 and WCAG 2.1 standards.
npm install color-contrast-checker
Typescript
Module System
Node Version
NPM Version
90.9
Supply Chain
100
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (90.52%)
HTML (9.48%)
Total Downloads
1,280,966
Last Day
1,604
Last Week
10,624
Last Month
48,331
Last Year
461,595
Apache-2.0 License
1 Stars
42 Commits
1 Forks
1 Branches
1 Contributors
Updated on Apr 15, 2025
Minified
Minified + Gzipped
Latest Version
2.1.0
Package Id
color-contrast-checker@2.1.0
Unpacked Size
36.04 kB
Size
8.96 kB
File Count
8
NPM Version
7.20.6
Node Version
14.15.4
Cumulative downloads
Total Downloads
Last Day
21.8%
1,604
Compared to previous day
Last Week
-4.1%
10,624
Compared to previous week
Last Month
5.9%
48,331
Compared to previous month
Last Year
10%
461,595
Compared to previous year
An accessibility checker tool for validating the color contrast based on WCAG 2.0 and WCAG 2.1 standard.
The formula (L1/L2) for contrast is based on [ISO-9241-3] and [ANSI-HFES-100-1988] standards as described here :
http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef http://www.w3.org/TR/WCAG20/#contrast-ratiodef https://www.w3.org/TR/WCAG21/#contrast-minimum
It also supports shorthand color codes e.g #FFF or #000 etc.
https://www.w3.org/TR/2001/WD-css3-color-20010305#colorunits
npm install color-contrast-checker
or using package.json
{
"name": "my-app",
..
"devDependencies": {
..
"color-contrast-checker": "2.1.0"
}
}
Then do npm install
To check specific WCAG levels
var ccc = new ColorContrastChecker();
var color1 = "#FFFFFF";
var color2 = "#000000;
if (ccc.isLevelAA(color1, color2, 14)) {
alert("Valid Level AA");
} else {
alert("Invalid Contrast");
}
To check custom ratios
var ccc = new ColorContrastChecker();
var color1 = "#FFFFFF";
var color2 = "#000000;
var customRatio = 5.7;
// No need for font size, now that we are using a custom ratio.
// This is because we are no longer checking against WCAG requirements.
if (ccc.isLevelCustom(color1, color2, customRatio)) {
alert("Above given ratio");
} else {
alert("Invalid Contrast");
}
You can pass pairs and get results:
var pairs = [
{
'colorA': '#000000',
'colorB': '#000000', // All should fail
'fontSize': 14
},
{
'colorA': '#000000',
'colorB': '#FFFFFF', //All should pass
'fontSize': 14
},
{
'colorA': '#000000',
'colorB': '#848484', //AAA should fail
'fontSize': 14
},
{
'colorA': '#000000',
'colorB': '#848484', //All should pass (because of font)
'fontSize': 19
},
{
'colorA': '#000000',
'colorB': '#757575', //AA should pass AAA should fail
'fontSize': 14
},
{
'colorA': '#000000',
'colorB': '#656565', //All should fail
'fontSize': 14
}
];
var results = ccc.checkPairs(pairs);
The result will look like this:
[
{
'WCAG_AA' : false,
'WCAG_AAA': false
},
{
'WCAG_AA' : true,
'WCAG_AAA': true
},
{
'WCAG_AA' : true,
'WCAG_AAA': false
},
{
'WCAG_AA' : true,
'WCAG_AAA': true
},
{
'WCAG_AA' : true,
'WCAG_AAA': false
},
{
'WCAG_AA' : false,
'WCAG_AAA': false
}
]
npm test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More