Big update!Introducing GitHub Bot Commands. Learn more
Log inBook a demo


Package Overview
File Explorer

Advanced tools


get colors in your node.js console


Version published
Weekly downloads
decreased by-2.11%

Weekly downloads



Primarily a release to update dependencies, but done as a minor version bump due to the renaming of the package.

  • Add recommended tsconfig.json via tsc --init 844545b
  • Force colors to work in GitHub Actions fd1fc03
  • Force colors to work in GitHub Actions ab74035
  • Run lint and npm audit fix 01a1edf
  • Update README c9e1be4
  • Update readme 6b57ae6
  • Rename package and replace CI with GitHub Actions fa97dc3
  • Update 627efe4
  • Merge pull request #1 from JJ/patch-1 9d5d779
  • Updating badges 509c543
  • naming d71da20
  • nvm 4edf6d5
  • increment 1855fcf
  • Update package name and URL 9470333
  • Update docs: missing semicolon in sample code (#273) 7ddd6a3



@colors/colors ("colors.js")

Build Status version

Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback.

get color and style in your node.js console



npm install @colors/colors

colors and styles!

text colors

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

bright text colors

  • brightRed
  • brightGreen
  • brightYellow
  • brightBlue
  • brightMagenta
  • brightCyan
  • brightWhite

background colors

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

bright background colors

  • bgBrightRed
  • bgBrightGreen
  • bgBrightYellow
  • bgBrightBlue
  • bgBrightMagenta
  • bgBrightCyan
  • bgBrightWhite


  • reset
  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough


  • rainbow
  • zebra
  • america
  • trap
  • random


By popular demand, @colors/colors now ships with two types of usages!

The super nifty way

var colors = require('@colors/colors'); console.log('hello'.green); // outputs green text console.log('i like cake and pies'; // outputs red underlined text console.log('inverse the color'.inverse); // inverses the color console.log('OMG Rainbows!'.rainbow); // rainbow console.log('Run the trap'.trap); // Drops the bass

or a slightly less nifty way which doesn't extend String.prototype

var colors = require('@colors/colors/safe'); console.log('hello')); // outputs green text console.log('i like cake and pies')); // outputs red underlined text console.log(colors.inverse('inverse the color')); // inverses the color console.log(colors.rainbow('OMG Rainbows!')); // rainbow console.log(colors.trap('Run the trap')); // Drops the bass

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.

Enabling/Disabling Colors

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:

node myapp.js --no-color node myapp.js --color=false node myapp.js --color node myapp.js --color=true node myapp.js --color=always FORCE_COLOR=1 node myapp.js

Or in code:

var colors = require('@colors/colors'); colors.enable(); colors.disable();

Console.log string substitution

var name = 'Beowulf'; console.log('Hello %s'), name); // outputs -> 'Hello Beowulf'

Custom themes

Using standard API

var colors = require('@colors/colors'); colors.setTheme({ silly: 'rainbow', input: 'grey', verbose: 'cyan', prompt: 'grey', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', debug: 'blue', error: 'red' }); // outputs red text console.log("this is an error".error); // outputs yellow text console.log("this is a warning".warn);

Using string safe API

var colors = require('@colors/colors/safe'); // set single property var error =; error('this is red'); // set theme colors.setTheme({ silly: 'rainbow', input: 'grey', verbose: 'cyan', prompt: 'grey', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', debug: 'blue', error: 'red' }); // outputs red text console.log(colors.error("this is an error")); // outputs yellow text console.log(colors.warn("this is a warning"));

Combining Colors

var colors = require('@colors/colors'); colors.setTheme({ custom: ['red', 'underline'] }); console.log('test'.custom);

Protip: There is a secret undocumented style in colors. If you find the style you can summon him.



What is @colors/colors?

get colors in your node.js console

Is @colors/colors popular?

The npm package @colors/colors receives a total of 10,377,804 weekly downloads. As such, @colors/colors popularity was classified as popular.

Is @colors/colors well maintained?

We found that @colors/colors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 12 Feb 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket


Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc