Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (63 sloc) 1.86 KB

cli-color - Yet another colors and formatting for the console solution

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



var clc = require('cli-color');

Output colored text:

console.log('Text in red'));

Styles can be mixed:

console.log('Underlined red text on white background.'));

Styled text can be mixed with unstyled:

console.log('red') + ' plain ' +'blue'));

Best way is to predefine needed stylings and then use it:

var error =;
var warn = clc.yellow;
var notice =;


Supported are all ANSI colors and styles:


Styles will display correctly if font used in your console supports them.

  • bold
  • italic
  • underline
  • inverse
  • strike

Foreground colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite

Additional functions:


Trims ANSI formatted string to plain text

var ansiTrim = require('cli-color/lib/trim');

var plain = ansiTrim(formatted);

throbber(interval[, format])

Displays throbber on given interval. Interval should be clock.interval object Optionally throbber output can be formatted with given format

var interval = require('clock/lib/interval')
  , ansiThrobber = require('cli-color/lib/throbber');

var i = interval(200, true);

// Display throbber while interval is ticking

// at any time you can stop/start interval
// When interval is stopped throbber doesn't show
Jump to Line
Something went wrong with that request. Please try again.