Skip to content

Function.stripAnsi

github-actions[bot] edited this page Jul 8, 2026 · 21 revisions

umt / stripAnsi

Function: stripAnsi()

stripAnsi(string_): string

Defined in: String/stripAnsi.ts:13

Removes ANSI escape sequences (e.g. terminal color codes) from a string, keeping the visible text. Unlike sanitizeString, which strips all non-printable characters, this targets only ANSI sequences. Handles CSI sequences (colors, cursor movement) and OSC sequences.

Parameters

string_

string

Input string

Returns

string

String without ANSI escape sequences

Example

stripAnsi("\u001B[31mred\u001B[0m"); // "red"

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally