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.
npm install strip-ansi
import stripAnsi from 'strip-ansi';
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
- strip-ansi-cli - CLI for this module
- strip-ansi-stream - Streaming version of this module
- has-ansi - Check if a string has ANSI escape codes
- ansi-regex - Regular expression for matching ANSI escape codes
- chalk - Terminal string styling done right