# cosmetic

> Chainable ANSI color and style encoding for Node.js terminals

Latest version **1.5.3** (published 2026-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install cosmetic
pnpm add cosmetic
yarn add cosmetic
bun add cosmetic
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.5.3 |
| Published | 2026-08-29 |
| First published | 2018-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Jay Deaton |
| Maintainers | jayrdeaton |
| Keywords | ansi, chainable, cli, color, console, terminal, styles, xterm |

## Links

- npm: https://www.npmjs.com/package/cosmetic
- Repository: https://github.com/jayrdeaton/Cosmetic
- Homepage: https://github.com/jayrdeaton/Cosmetic#readme
- Issues: https://github.com/jayrdeaton/Cosmetic/issues
- npm.io page: https://npm.io/package/cosmetic

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.5.3 (latest) — 2026-08-29
- 1.5.2 — 2026-08-29
- 1.5.1 — 2026-08-27
- 1.5.0 — 2026-07-25
- 1.4.2 — 2026-06-07
- 1.4.1 — 2026-06-05
- 1.4.0 — 2026-05-30
- 1.3.3 — 2026-03-27
- 1.2.1 — 2019-11-01
- 1.2.0 — 2019-05-23
- 1.1.2 — 2019-04-22
- 1.1.1 — 2018-02-04
- 1.1.0 — 2018-02-04
- 1.0.1 — 2018-02-03
- 1.0.0 — 2018-02-03

## README

# Cosmetic

A chainable ANSI color and style library for Node.js terminals

## Getting Started

### Installing

```bash
npm install cosmetic
```

### Using

```js
// ESM
import cosmetic from 'cosmetic'

// CJS
const cosmetic = require('cosmetic')

console.log(cosmetic.green('Success!'))
```

### Styles

```js
cosmetic.bold('Bold')
cosmetic.faint('Faint')
cosmetic.italic('Italic')
cosmetic.underline('Underline')
cosmetic.blink('Blink')
cosmetic.rapidBlink('Rapid Blink') // Not always supported
cosmetic.reverse('Reverse')
cosmetic.conceal('Conceal')
```

### Colors

The basic 8 colors support regular, bright, foreground, and background variants:

```js
cosmetic.red('Red')
cosmetic.bright.red('Bright Red')
cosmetic.background.red('Background Red')
cosmetic.bright.background.red('Bright Background Red')
```

Available colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`

### Chaining

Styles are chainable:

```js
cosmetic.underline.green('Underlined green text')
cosmetic.bold.bright.background.red('Bold bright red background')
```

### Xterm

All 256 Xterm colors:

```js
cosmetic.xterm(42)('Foreground')
cosmetic.background.xterm(42)('Background')
```

### True Color

24-bit color via hex or RGB:

```js
cosmetic.hex('#ff6b35')('Hex foreground')
cosmetic.background.hex('#1a1a2e')('Hex background')

cosmetic.rgb(255, 107, 53)('RGB foreground')
cosmetic.background.rgb(26, 26, 46)('RGB background')
```

## TypeScript

The `Cosmetic` type represents the default export and is useful for annotating variables or parameters:

```ts
import cosmetic, { type Cosmetic } from 'cosmetic'

function createLogger(color: Cosmetic) {
  return (message: string) => color(message)
}

const warn = createLogger(cosmetic.yellow)
const error = createLogger(cosmetic.bright.red)
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

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