A parser for ANSI escape sequences that tokenizes input into structured objects with foreground/background colors and decorations. Current stable version is 1.1.3. Released with minor features and bug fixes since its initial v1.0.0 in 2023. Key differentiator: it supports incremental parsing via a stateful parser, provides a color palette to interpret named, table, and RGB colors as hex codes, and ships TypeScript types. Suitable for generating pretty HTML or custom rendering from terminal output.
npm install ansi-sequence-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing ANSI sequences and converting colors to hex using the default color palette.
Upgrade to v1.1.1 or later.
Provide a full custom palette or extend the default with defaultNamedColorsMap.
Always ensure sequences are terminated with a letter (e.g., 'm') to avoid parsing issues.
Pre-process input to remove non-SGR sequences if needed, or use a more complete parser.
Run 'npm install ansi-sequence-parser' and ensure your project uses ESM (type: 'module' in package.json or .mjs extension).
Use: import { parseAnsiSequences } from 'ansi-sequence-parser'Check token.foreground or token.background for null before calling palette.value().
No dependency data recorded yet.