# ansi-color

> This module provides basic ANSI color code support, to allow you to format your console output with foreground and background colors as well as providing bold, italic and underline support.

Latest version **0.2.2** (published 2025-12-11) · BSD License license · 0 weekly downloads

## Install

```sh
npm install ansi-color
pnpm add ansi-color
yarn add ansi-color
bun add ansi-color
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2025-12-11 |
| First published | 2015-01-01 |
| Weekly downloads | 0 |
| License | BSD License |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | James Smith |
| Maintainers | loopj |
| Keywords | ansi, color, console |

## Links

- npm: https://www.npmjs.com/package/ansi-color
- Repository: https://github.com/loopj/commonjs-ansi-color
- Issues: https://github.com/loopj/commonjs-ansi-color/issues
- npm.io page: https://npm.io/package/ansi-color

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.2.2 (latest) — 2025-12-11
- 0.2.1 — 2015-01-01

## README

ANSI Color Code Output Support for CommonJS + Node.js
===========================================

This CommonJS module provides basic ANSI color code support, to allow you to
format your console output with foreground and background colors as well as
providing bold and underline support.

This module does not modify any built-in object prototypes, and so is safe
to use with other modules.

Tested on node.js.

Basic usage:
-----------
    // Load the module
    var color = require("ansi-color").set;

    // Print the word "Error" to stdout in red
    console.log(color("Error", "red"));

    // Print the word "Error" in red and underlined
    console.log(color("Error", "red+underline"));

    // Print the word "Success" in bold green, followed by a message
    console.log(color("Success", "green+bold"), "Something was successful!");

Supported Colors/Formats:
-------------------------
Note: Any of the below formatting strings can be combined together by joining
together desired formats with a + symbol. Eg: bold+cyan+white_bg

- Bold Text: bold
- Underlined Text: underline
- Blinking Text: blink
- Black Text: black
- Red Text: red
- Green Text: green
- Yellow Text: yellow
- Blue Text: blue
- Magenta Text: magenta
- Cyan Text: cyan
- White Text: white
- Black Background: black_bg
- Red Background: red_bg
- Green Background: green_bg
- Yellow Background: yellow_bg
- Blue Background: blue_bg
- Magenta Background: magenta_bg
- Cyan Background: cyan_bg
- White Background: white_bg

---
_Source: https://npm.io/package/ansi-color · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
