githubEdit

ansi-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).

Please consider following this project's author, Brian Woodwardarrow-up-right, and consider starring the project to show your ❤️ and support.

Install

Install with npmarrow-up-right:

$ npm install --save ansi-colors
image

Why use this?

ansi-colors is the fastest Node.js library for terminal styling. A more performant drop-in replacement for chalk, with no dependencies.

Usage

image

Chained colors

image

Nested colors

image

Nested styling bug

ansi-colors does not have the nested styling bug found in colorettearrow-up-right, chalkarrow-up-right, and kleurarrow-up-right.

Results in the following

(sans icons and labels)

image

Toggle color support

Easily enable/disable colors.

Strip ANSI codes

Use the .unstyle method to strip ANSI codes from a string.

Available styles

Note that bright and bright-background colors are not always supported.

Colors
Background Colors
Bright Colors
Bright Background Colors

black

bgBlack

blackBright

bgBlackBright

red

bgRed

redBright

bgRedBright

green

bgGreen

greenBright

bgGreenBright

yellow

bgYellow

yellowBright

bgYellowBright

blue

bgBlue

blueBright

bgBlueBright

magenta

bgMagenta

magentaBright

bgMagentaBright

cyan

bgCyan

cyanBright

bgCyanBright

white

bgWhite

whiteBright

bgWhiteBright

gray

grey

(gray is the U.S. spelling, grey is more commonly used in the Canada and U.K.)

Style modifiers

  • dim

  • bold

  • hidden

  • italic

  • underline

  • inverse

  • strikethrough

  • reset

Performance

Libraries tested

  • ansi-colors v3.0.4

  • chalk v2.4.1

Mac

MacBook Pro, Intel Core i7, 2.3 GHz, 16 GB.

Load time

Time it takes to load the first time require() is called:

  • ansi-colors - 1.915ms

  • chalk - 12.437ms

Benchmarks

Windows

Windows 10, Intel Core i7-7700k CPU @ 4.2 GHz, 32 GB

Load time

Time it takes to load the first time require() is called:

  • ansi-colors - 1.494ms

  • chalk - 11.523ms

Benchmarks

About

chevron-rightContributinghashtag

Pull requests and stars are always welcome. For bugs and feature requests, please create an issuearrow-up-right.

chevron-rightRunning Testshashtag

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

chevron-rightBuilding docshashtag

(This project's readme.md is generated by verbarrow-up-right, please don't edit the readme directly. Any changes to the readme must be made in the .verb.mdarrow-up-right readme template.)

To generate the readme, run the following command:

You might also be interested in these projects:

Contributors

Author

Brian Woodward

Please consider supporting me on Patreon, or start your own Patreon pagearrow-up-right!

arrow-up-right

License

Copyright © 2019, Brian Woodwardarrow-up-right. Released under the MIT Licensearrow-up-right.


This file was generated by verb-generate-readmearrow-up-right, v0.8.0, on March 03, 2019.

Last updated