sindresorhus/strip-ansi

Strip ANSI escape codes from a string

498

stars

71

commits

JavaScript

primary language

Feb 26, 2026

updated

README

strip-ansi

Strip ANSI escape codes from a string

[!NOTE] Node.js has this built-in now with stripVTControlCharacters. 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

npm install strip-ansi

Usage

import stripAnsi from 'strip-ansi';

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

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

Maintainers

Contributors

sindresorhus

57 commits

LitoMore

2 commits

jbnicolai

2 commits

kevva

2 commits

sindresorhus/strip-ansi

Strip ANSI escape codes from a string

498

stars

71

commits

JavaScript

primary language

Feb 26, 2026

updated

README

strip-ansi

Strip ANSI escape codes from a string

[!NOTE] Node.js has this built-in now with stripVTControlCharacters. 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

npm install strip-ansi

Usage

import stripAnsi from 'strip-ansi';

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

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

Maintainers

Contributors

sindresorhus

57 commits

LitoMore

2 commits

jbnicolai

2 commits

kevva

2 commits

Languages

JavaScript

93.4%

TypeScript

6.6%