Gathering detailed insights and metrics for cli-color
Gathering detailed insights and metrics for cli-color
Gathering detailed insights and metrics for cli-color
Gathering detailed insights and metrics for cli-color
npm install cli-color
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
677 Stars
335 Commits
34 Forks
8 Watchers
3 Branches
7 Contributors
Updated on Jun 23, 2025
Latest Version
2.0.4
Package Id
cli-color@2.0.4
Unpacked Size
38.69 kB
Size
13.84 kB
File Count
24
NPM Version
10.2.4
Node Version
20.11.1
Published on
Feb 29, 2024
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
Colors, formatting and other goodies for the console. This package won't mess with built-ins and provides neat way to predefine formatting patterns, see below.
$ npm install cli-color
Usage:
1var clc = require("cli-color");
Output colored text:
1console.log(clc.red("Text in red"));
Styles can be mixed:
1console.log(clc.red.bgWhite.underline("Underlined red text on white background."));
Styled text can be mixed with unstyled:
1console.log(clc.red("red") + " plain " + clc.blue("blue"));
Styled text can be nested:
1console.log(clc.red("red " + clc.blue("blue") + " red"));
Best way is to predefine needed stylings and then use it:
1var error = clc.red.bold; 2var warn = clc.yellow; 3var notice = clc.blue; 4 5console.log(error("Error!")); 6console.log(warn("Warning")); 7console.log(notice("Notice"));
Note: No colors or styles are output when NO_COLOR
env var is set
Supported are all ANSI colors and styles:
Styles will display correctly if font used in your console supports them.
Foreground | Background | |
---|---|---|
black | bgBlack | ![]() |
red | bgRed | ![]() |
green | bgGreen | ![]() |
yellow | bgYellow | ![]() |
blue | bgBlue | ![]() |
magenta | bgMagenta | ![]() |
cyan | bgCyan | ![]() |
white | bgWhite | ![]() |
Foreground | Background | |
---|---|---|
blackBright | bgBlackBright | ![]() |
redBright | bgRedBright | ![]() |
greenBright | bgGreenBright | ![]() |
yellowBright | bgYellowBright | ![]() |
blueBright | bgBlueBright | ![]() |
magentaBright | bgMagentaBright | ![]() |
cyanBright | bgCyanBright | ![]() |
whiteBright | bgWhiteBright | ![]() |
Not supported on Windows and some terminals. However if used in not supported environment, the closest color from basic (16 colors) palette is chosen.
Usage:
1var msg = clc.xterm(202).bgXterm(236); 2console.log(msg("Orange text on dark gray background"));
Color table:
Terminal can be cleared with clc.reset
1process.stdout.write(clc.reset);
Entire screen
1process.stdout.write(clc.erase.screen);
Left portion of a screen
1process.stdout.write(clc.erase.screenLeft);
Right portion of a screen
1process.stdout.write(clc.erase.screenRight);
Current line
1process.stdout.write(clc.erase.line);
Right portion of current line
1process.stdout.write(clc.erase.lineRight);
Left portion of current line
1process.stdout.write(clc.erase.lineLeft);
Move cursor x columns and y rows away. Values can be positive or negative, e.g.:
1process.stdout.write(clc.move(-2, -2)); // Move cursors two columns and two rows back
Absolute move. Sets cursor position at x column and y row
1process.stdout.write(clc.move.to(0, 0)); // Move cursor to first row and first column in terminal window
Move cursor up n rows
1process.stdout.write(clc.move.up(2));
Move cursor down n rows
1process.stdout.write(clc.move.down(2));
Move cursor right n columns
1process.stdout.write(clc.move.right(2));
Move cursor left n columns
1process.stdout.write(clc.move.left(2));
Move cursor n
lines forward if n
is positive, otherwise n
lines backward, and place it at line beginning
1process.stdout.write(clc.move.lines(2));
Move cursor to top of a screen
1process.stdout.write(clc.move.top);
Move cursor to bottom of a screen
1process.stdout.write(clc.move.bottom);
Move cursor to begin of a line
1process.stdout.write(clc.move.lineBegin);
Move cursor to end of a line
1process.stdout.write(clc.move.lineEnd);
Returns terminal width
Returns terminal height
Slice provided string with preservation of eventual ANSI formatting
1var clc = require("cli-color"); 2 3var str = clc.bold("foo") + "bar" + clc.red("elo"); 4var sliced = clc.slice(str, 1, 7); // Same as: clc.bold('oo') + 'bar' + clc.red('e')
Strips ANSI formatted string to plain text
1var ansiStrip = require("cli-color/strip"); 2 3var plain = ansiStrip(formatted);
Get actual length of ANSI-formatted string
1var clc = require("cli-color"); 2 3var str = clc.bold("foo") + "bar" + clc.red("elo"); 4clc.getStrippedLength(str); // 9
Create a text-graphical art. Within styleConf
, string replacements needs to be defined, which are then used to convert text
to styled graphical text.
1var text = ".........\n" + ". Hello .\n" + ".........\n"; 2var style = { ".": clc.yellowBright("X") }; 3 4process.stdout.write(clc.art(text, style));
Outputs aligned table of columns.
data
is expected to be an array (or other iterable structure) of rows, where each row is also an array (or other iterable structure) of content to display.
Supported options
:
sep
: Custom colums separator (defaults to |
)columns
: Per column customizations, as e.g. [{ align: 'right' }, null, { align: 'left' }]
:
align
: Possible options: 'left'
, 'right
(efaults to 'left'
)1var clc = require("cli-color"); 2 3process.stdout.write( 4 clc.columns([ 5 [clc.bold("First Name"), clc.bold("Last Name"), clc.bold("Age")], 6 ["John", "Doe", 34], 7 ["Martha", "Smith", 20], 8 ["Jan", "Kowalski", 30] 9 ]) 10); 11 12/* Outputs: 13 14First Name | Last Name | Age 15John | Doe | 34 16Martha | Smith | 20 17Jan | Kowalski | 30 18*/
Writes throbber string to write function at given interval. Optionally throbber output can be formatted with given format function
1var setupThrobber = require("cli-color/throbber"); 2 3var throbber = setupThrobber(function (str) { process.stdout.write(str); }, 200); 4 5throbber.start(); 6 7// at any time you can stop/start throbber 8throbber.stop();
$ npm test
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
clc.art
module, and significant improvements to tests coverageclc.slice
functionality, and introduction of clc.getStrippedLength
utilityNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
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
dependency not pinned by hash detected -- score normalized to 0
Details
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
Score
Last Scanned on 2025-07-07
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