Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
npm install colors
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
100
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
5,190 Stars
259 Commits
450 Forks
52 Watchers
2 Branches
43 Contributors
Updated on Jul 12, 2025
Latest Version
1.4.0
Package Id
colors@1.4.0
Size
11.00 kB
NPM Version
6.9.0
Node Version
10.16.3
Published on
Sep 22, 2019
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback, and check the develop
branch for the latest bleeding-edge updates.
npm install colors
By popular demand, colors
now ships with two types of usages!
The super nifty way
1var colors = require('colors'); 2 3console.log('hello'.green); // outputs green text 4console.log('i like cake and pies'.underline.red) // outputs red underlined text 5console.log('inverse the color'.inverse); // inverses the color 6console.log('OMG Rainbows!'.rainbow); // rainbow 7console.log('Run the trap'.trap); // Drops the bass 8
or a slightly less nifty way which doesn't extend String.prototype
1var colors = require('colors/safe'); 2 3console.log(colors.green('hello')); // outputs green text 4console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text 5console.log(colors.inverse('inverse the color')); // inverses the color 6console.log(colors.rainbow('OMG Rainbows!')); // rainbow 7console.log(colors.trap('Run the trap')); // Drops the bass 8
I prefer the first way. Some people seem to be afraid of extending String.prototype
and prefer the second way.
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch String.prototype
, the second usage will not touch String
native object.
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
1node myapp.js --no-color 2node myapp.js --color=false 3 4node myapp.js --color 5node myapp.js --color=true 6node myapp.js --color=always 7 8FORCE_COLOR=1 node myapp.js
Or in code:
1var colors = require('colors'); 2colors.enable(); 3colors.disable();
1var name = 'Marak'; 2console.log(colors.green('Hello %s'), name); 3// outputs -> 'Hello Marak'
1 2var colors = require('colors'); 3 4colors.setTheme({ 5 silly: 'rainbow', 6 input: 'grey', 7 verbose: 'cyan', 8 prompt: 'grey', 9 info: 'green', 10 data: 'grey', 11 help: 'cyan', 12 warn: 'yellow', 13 debug: 'blue', 14 error: 'red' 15}); 16 17// outputs red text 18console.log("this is an error".error); 19 20// outputs yellow text 21console.log("this is a warning".warn);
1var colors = require('colors/safe'); 2 3// set single property 4var error = colors.red; 5error('this is red'); 6 7// set theme 8colors.setTheme({ 9 silly: 'rainbow', 10 input: 'grey', 11 verbose: 'cyan', 12 prompt: 'grey', 13 info: 'green', 14 data: 'grey', 15 help: 'cyan', 16 warn: 'yellow', 17 debug: 'blue', 18 error: 'red' 19}); 20 21// outputs red text 22console.log(colors.error("this is an error")); 23 24// outputs yellow text 25console.log(colors.warn("this is a warning")); 26
1var colors = require('colors'); 2 3colors.setTheme({ 4 custom: ['red', 'underline'] 5}); 6 7console.log('test'.custom);
Protip: There is a secret undocumented style in colors
. If you find the style you can summon him.
7.5/10
Summary
Infinite Loop in colors.js
Affected Versions
>= 1.4.1
0/10
Summary
Infinite loop causing Denial of Service in colors
Affected Versions
= 1.4.44-liberty-2
0/10
Summary
Infinite loop causing Denial of Service in colors
Affected Versions
>= 1.4.1, <= 1.4.2
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/24 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
17 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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 Moreansi-colors
Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).
@colors/colors
get colors in your node.js console
@ant-design/colors
Color palettes calculator of Ant Design
material-colors
Colors of Google's Material Design made available to coders