Convert ANSI escape codes (e.g., terminal colors) to formatted React elements. Current stable version: 6.2.6 (January 2026). Maintained by nteract, ships TypeScript types, supports React 16.3+ through 19. Supports both inline styles and CSS classes. Lightweight, no dependencies beyond React and react-dom peer deps.
npm install ansi-to-reactVerified import paths — ran on the pinned version, not inferred.
Renders a string with ANSI escape codes as styled React elements using default inline styles.
Use `import Ansi from 'ansi-to-react'` instead of `import { Ansi } from 'ansi-to-react'`.Use `const Ansi = require('ansi-to-react').default`.Always validate or sanitize input ANSI strings before passing to the component if you expect strict parsing.
Upgrade to v6 which uses modern React patterns and hooks.
Change to `import Ansi from 'ansi-to-react'`.
If using ESM, import default; if CJS, const Ansi = require('ansi-to-react').default;Run `npm install ansi-to-react` or `yarn add ansi-to-react`.