{"id":13464837,"url":"https://github.com/doowb/ansi-colors","last_synced_at":"2025-05-14T21:04:00.317Z","repository":{"id":37773784,"uuid":"47135420","full_name":"doowb/ansi-colors","owner":"doowb","description":"Easily add ANSI colors to your text and symbols in the terminal. ansi-colors is the official ansi styling library for gulp. Used by hundreds of projects, including enquirer, vscode, codeql, azure data studio, aws-cdk, redwoodjs, leaflet, mocha, and many others.","archived":false,"fork":false,"pushed_at":"2022-07-11T19:47:40.000Z","size":128,"stargazers_count":446,"open_issues_count":15,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T06:04:41.847Z","etag":null,"topics":["ansi","ansi-colors","blue","bold","chalk","colors","cyan","dim","gray","green","grey","javascript","kleur","magenta","node","nodejs","red","symbols","white","yellow"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doowb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-30T17:42:04.000Z","updated_at":"2025-03-16T19:14:20.000Z","dependencies_parsed_at":"2022-08-14T09:30:22.814Z","dependency_job_id":null,"html_url":"https://github.com/doowb/ansi-colors","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fansi-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fansi-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fansi-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fansi-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/ansi-colors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571886,"owners_count":21126522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","ansi-colors","blue","bold","chalk","colors","cyan","dim","gray","green","grey","javascript","kleur","magenta","node","nodejs","red","symbols","white","yellow"],"created_at":"2024-07-31T14:00:51.353Z","updated_at":"2025-04-13T16:09:41.292Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68"],"categories":["JavaScript"],"sub_categories":[],"readme":"# ansi-colors [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/ansi-colors.svg?style=flat)](https://www.npmjs.com/package/ansi-colors) [![NPM monthly downloads](https://img.shields.io/npm/dm/ansi-colors.svg?style=flat)](https://npmjs.org/package/ansi-colors) [![NPM total downloads](https://img.shields.io/npm/dt/ansi-colors.svg?style=flat)](https://npmjs.org/package/ansi-colors) [![Linux Build Status](https://img.shields.io/travis/doowb/ansi-colors.svg?style=flat\u0026label=Travis)](https://travis-ci.org/doowb/ansi-colors)\n\n\u003e 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).\n\nPlease consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save ansi-colors\n```\n\n![image](https://user-images.githubusercontent.com/383994/39635445-8a98a3a6-4f8b-11e8-89c1-068c45d4fff8.png)\n\n## Why use this?\n\nansi-colors is _the fastest Node.js library for terminal styling_. A more performant drop-in replacement for chalk, with no dependencies.\n\n* _Blazing fast_ - Fastest terminal styling library in node.js, 10-20x faster than chalk!\n\n* _Drop-in replacement_ for [chalk](https://github.com/chalk/chalk).\n* _No dependencies_ (Chalk has 7 dependencies in its tree!)\n\n* _Safe_ - Does not modify the `String.prototype` like [colors](https://github.com/Marak/colors.js).\n* Supports [nested colors](#nested-colors), **and does not have the [nested styling bug](#nested-styling-bug) that is present in [colorette](https://github.com/jorgebucaran/colorette), [chalk](https://github.com/chalk/chalk), and [kleur](https://github.com/lukeed/kleur)**.\n* Supports [chained colors](#chained-colors).\n* [Toggle color support](#toggle-color-support) on or off.\n\n## Usage\n\n```js\nconst c = require('ansi-colors');\n\nconsole.log(c.red('This is a red string!'));\nconsole.log(c.green('This is a red string!'));\nconsole.log(c.cyan('This is a cyan string!'));\nconsole.log(c.yellow('This is a yellow string!'));\n```\n\n![image](https://user-images.githubusercontent.com/383994/39653848-a38e67da-4fc0-11e8-89ae-98c65ebe9dcf.png)\n\n## Chained colors\n\n```js\nconsole.log(c.bold.red('this is a bold red message'));\nconsole.log(c.bold.yellow.italic('this is a bold yellow italicized message'));\nconsole.log(c.green.bold.underline('this is a bold green underlined message'));\n```\n\n![image](https://user-images.githubusercontent.com/383994/39635780-7617246a-4f8c-11e8-89e9-05216cc54e38.png)\n\n## Nested colors\n\n```js\nconsole.log(c.yellow(`foo ${c.red.bold('red')} bar ${c.cyan('cyan')} baz`));\n```\n\n![image](https://user-images.githubusercontent.com/383994/39635817-8ed93d44-4f8c-11e8-8afd-8c3ea35f5fbe.png)\n\n### Nested styling bug\n\n`ansi-colors` does not have the nested styling bug found in [colorette](https://github.com/jorgebucaran/colorette), [chalk](https://github.com/chalk/chalk), and [kleur](https://github.com/lukeed/kleur).\n\n```js\nconst { bold, red } = require('ansi-styles');\nconsole.log(bold(`foo ${red.dim('bar')} baz`));\n\nconst colorette = require('colorette');\nconsole.log(colorette.bold(`foo ${colorette.red(colorette.dim('bar'))} baz`));\n\nconst kleur = require('kleur');\nconsole.log(kleur.bold(`foo ${kleur.red.dim('bar')} baz`));\n\nconst chalk = require('chalk');\nconsole.log(chalk.bold(`foo ${chalk.red.dim('bar')} baz`));\n```\n\n**Results in the following**\n\n(sans icons and labels)\n\n![image](https://user-images.githubusercontent.com/383994/47280326-d2ee0580-d5a3-11e8-9611-ea6010f0a253.png)\n\n## Toggle color support\n\nEasily enable/disable colors.\n\n```js\nconst c = require('ansi-colors');\n\n// disable colors manually\nc.enabled = false;\n\n// or use a library to automatically detect support\nc.enabled = require('color-support').hasBasic;\n\nconsole.log(c.red('I will only be colored red if the terminal supports colors'));\n```\n\n## Strip ANSI codes\n\nUse the `.unstyle` method to strip ANSI codes from a string.\n\n```js\nconsole.log(c.unstyle(c.blue.bold('foo bar baz')));\n//=\u003e 'foo bar baz'\n```\n\n## Available styles\n\n**Note** that bright and bright-background colors are not always supported.\n\n| Colors  | Background Colors | Bright Colors | Bright Background Colors |\n| ------- | ----------------- | ------------- | ------------------------ |\n| black   | bgBlack           | blackBright   | bgBlackBright            |\n| red     | bgRed             | redBright     | bgRedBright              |\n| green   | bgGreen           | greenBright   | bgGreenBright            |\n| yellow  | bgYellow          | yellowBright  | bgYellowBright           |\n| blue    | bgBlue            | blueBright    | bgBlueBright             |\n| magenta | bgMagenta         | magentaBright | bgMagentaBright          |\n| cyan    | bgCyan            | cyanBright    | bgCyanBright             |\n| white   | bgWhite           | whiteBright   | bgWhiteBright            |\n| gray    |                   |               |                          |\n| grey    |                   |               |                          |\n\n_(`gray` is the U.S. spelling, `grey` is more commonly used in the Canada and U.K.)_\n\n### Style modifiers\n\n* dim\n* **bold**\n\n* hidden\n* _italic_\n\n* underline\n* inverse\n* ~~strikethrough~~\n\n* reset\n\n## Aliases\n\nCreate custom aliases for styles.\n\n```js\nconst colors = require('ansi-colors');\n\ncolors.alias('primary', colors.yellow);\ncolors.alias('secondary', colors.bold);\n\nconsole.log(colors.primary.secondary('Foo'));\n```\n\n## Themes\n\nA theme is an object of custom aliases.\n\n```js\nconst colors = require('ansi-colors');\n\ncolors.theme({\n  danger: colors.red,\n  dark: colors.dim.gray,\n  disabled: colors.gray,\n  em: colors.italic,\n  heading: colors.bold.underline,\n  info: colors.cyan,\n  muted: colors.dim,\n  primary: colors.blue,\n  strong: colors.bold,\n  success: colors.green,\n  underline: colors.underline,\n  warning: colors.yellow\n});\n\n// Now, we can use our custom styles alongside the built-in styles!\nconsole.log(colors.danger.strong.em('Error!'));\nconsole.log(colors.warning('Heads up!'));\nconsole.log(colors.info('Did you know...'));\nconsole.log(colors.success.bold('It worked!'));\n```\n\n## Performance\n\n**Libraries tested**\n\n* ansi-colors v3.0.4\n* chalk v2.4.1\n\n### Mac\n\n\u003e MacBook Pro, Intel Core i7, 2.3 GHz, 16 GB.\n\n**Load time**\n\nTime it takes to load the first time `require()` is called:\n\n* ansi-colors - `1.915ms`\n* chalk - `12.437ms`\n\n**Benchmarks**\n\n```\n# All Colors\n  ansi-colors x 173,851 ops/sec ±0.42% (91 runs sampled)\n  chalk x 9,944 ops/sec ±2.53% (81 runs sampled)))\n\n# Chained colors\n  ansi-colors x 20,791 ops/sec ±0.60% (88 runs sampled)\n  chalk x 2,111 ops/sec ±2.34% (83 runs sampled)\n\n# Nested colors\n  ansi-colors x 59,304 ops/sec ±0.98% (92 runs sampled)\n  chalk x 4,590 ops/sec ±2.08% (82 runs sampled)\n```\n\n### Windows\n\n\u003e Windows 10, Intel Core i7-7700k CPU @ 4.2 GHz, 32 GB\n\n**Load time**\n\nTime it takes to load the first time `require()` is called:\n\n* ansi-colors - `1.494ms`\n* chalk - `11.523ms`\n\n**Benchmarks**\n\n```\n# All Colors\n  ansi-colors x 193,088 ops/sec ±0.51% (95 runs sampled))\n  chalk x 9,612 ops/sec ±3.31% (77 runs sampled)))\n\n# Chained colors\n  ansi-colors x 26,093 ops/sec ±1.13% (94 runs sampled)\n  chalk x 2,267 ops/sec ±2.88% (80 runs sampled))\n\n# Nested colors\n  ansi-colors x 67,747 ops/sec ±0.49% (93 runs sampled)\n  chalk x 4,446 ops/sec ±3.01% (82 runs sampled))\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [ansi-wrap](https://www.npmjs.com/package/ansi-wrap): Create ansi colors by passing the open and close codes. | [homepage](https://github.com/jonschlinkert/ansi-wrap \"Create ansi colors by passing the open and close codes.\")\n* [strip-color](https://www.npmjs.com/package/strip-color): Strip ANSI color codes from a string. No dependencies. | [homepage](https://github.com/jonschlinkert/strip-color \"Strip ANSI color codes from a string. No dependencies.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 48 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 42 | [doowb](https://github.com/doowb) |  \n| 6  | [lukeed](https://github.com/lukeed) |  \n| 2  | [Silic0nS0ldier](https://github.com/Silic0nS0ldier) |  \n| 1  | [dwieeb](https://github.com/dwieeb) |  \n| 1  | [jorgebucaran](https://github.com/jorgebucaran) |  \n| 1  | [madhavarshney](https://github.com/madhavarshney) |  \n| 1  | [chapterjason](https://github.com/chapterjason) |  \n\n### Author\n\n**Brian Woodward**\n\n* [GitHub Profile](https://github.com/doowb)\n* [Twitter Profile](https://twitter.com/doowb)\n* [LinkedIn Profile](https://linkedin.com/in/woodwardbrian)\n\n### License\n\nCopyright © 2019, [Brian Woodward](https://github.com/doowb).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 01, 2019._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fansi-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Fansi-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fansi-colors/lists"}