Utilities
util.stripVTControlCharacters()
Removes recognized terminal control sequences from a string. This is useful for readable logs, but not a general sanitizer for HTML, shell input or every potentially misleading Unicode character. Tested on Node.js 22.16.0. Example output (one line per entry): ["red"].
Formal Syntax & Structure
nodejs syntaxnodejs
util.stripVTControlCharacters(str)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| str | string | Input text. |
Return Value
string
Text with recognized VT sequences removed.
Working Example
Example Snippetnodejs
import { stripVTControlCharacters } from 'node:util';console.log(stripVTControlCharacters('\x1b[31mred\x1b[0m'));