# strip-ansi

> Strip ANSI escape codes from a string

Latest version **7.2.0** (published 2026-02-26) · MIT license · 0 weekly downloads

> **Better alternative:** See documentation for alternatives (https://github.com/AikidoSec/module-replacements/blob/main/docs/strip-ansi)

## Install

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

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.2.0 |
| Published | 2026-02-26 |
| First published | 2013-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 498 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | strip, trim, remove, ansi, styles, color, colour, colors, terminal, console, string, tty, escape, formatting, rgb, 256, shell, xterm, log, logging, command-line, text |

## Links

- npm: https://www.npmjs.com/package/strip-ansi
- Repository: https://github.com/chalk/strip-ansi
- Homepage: https://github.com/chalk/strip-ansi#readme
- Issues: https://github.com/chalk/strip-ansi/issues
- Funding: https://github.com/chalk/strip-ansi?sponsor=1
- npm.io page: https://npm.io/package/strip-ansi

## Dependencies (1)

- [ansi-regex](https://npm.io/package/ansi-regex.md) ^6.2.2

## 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

- 7.2.0 (latest) — 2026-02-26
- 6.0.1 (version6) — 2021-09-23
- 7.1.2 — 2025-09-08
- 7.1.0 — 2023-05-28
- 7.0.1 — 2021-09-11
- 7.0.0 — 2021-04-16
- 6.0.0 — 2019-11-09
- 5.2.0 — 2019-03-18
- 5.1.0 — 2019-03-08
- 5.0.0 — 2018-09-29
- 4.0.0 — 2017-06-20
- 3.0.1 — 2016-02-21
- 3.0.0 — 2015-06-30
- 2.0.1 — 2015-01-16
- 2.0.0 — 2014-08-13
- … 7 more at https://npm.io/package/strip-ansi/versions

## README

# strip-ansi

> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string

> [!NOTE]
> Node.js has this built-in now with [`stripVTControlCharacters`](https://nodejs.org/api/util.html#utilstripvtcontrolcharactersstr). The benefit of this package is consistent behavior across Node.js versions and faster improvements. The Node.js version is actually based on this package.

## Install

```sh
npm install strip-ansi
```

## Usage

```js
import stripAnsi from 'strip-ansi';

stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'

stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```

## Related

- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right

## Maintainers

- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

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