# ansi-to-react

> ANSI to React Elements

Latest version **6.2.6** (published 2026-01-24) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install ansi-to-react
pnpm add ansi-to-react
yarn add ansi-to-react
bun add ansi-to-react
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 6.2.6 |
| Published | 2026-01-24 |
| First published | 2016-01-05 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 98 |
| Author | Kyle Kelley |
| Maintainers | benabel, alexandercbooth, benrussert, mpacer, theengineear, yuvipanda, rgbkrk, lgeiger, ivanov, captainsafia, peggyrayzis, jdetle, hasch, willingc, stormpython, crystalline-cat, emeeks, hydrosquall, gnestor |
| Keywords | ansi, react |

## Links

- npm: https://www.npmjs.com/package/ansi-to-react
- Repository: https://github.com/nteract/ansi-to-react
- Homepage: https://github.com/nteract/ansi-to-react#readme
- Issues: https://github.com/nteract/ansi-to-react/issues
- npm.io page: https://npm.io/package/ansi-to-react

## Dependencies (3)

- [anser](https://npm.io/package/anser.md) ^2.3.2
- [linkify-it](https://npm.io/package/linkify-it.md) ^3.0.3
- [escape-carriage](https://npm.io/package/escape-carriage.md) ^1.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 6.2.6 (latest) — 2026-01-24
- 6.0.5-alpha.0 (prerelease) — 2020-03-10
- 6.1.6 — 2021-07-29
- 6.1.5 — 2021-04-30
- 6.1.4 — 2020-12-11
- 6.1.3 — 2020-12-11
- 6.1.2 — 2020-12-11
- 6.1.1 — 2020-12-09
- 6.1.0 — 2020-12-03
- 6.0.10 — 2020-12-01
- 6.0.8 — 2020-09-08
- 6.0.7 — 2020-06-03
- 6.0.6 — 2020-05-31
- 6.0.5 — 2020-03-11
- 6.0.4-alpha.0 — 2020-03-03
- … 53 more at https://npm.io/package/ansi-to-react/versions

## README

# ansi-to-react

This package convert ANSI escape codes to formatted text output for React.

## Installation

```
$ pnpm add ansi-to-react
```

## Usage

### Basic

The example below shows how we can use this package to render a string with ANSI escape codes.

```javascript
import Ansi from "ansi-to-react";

export function () => {
  return <Ansi>
    {'\u001b[34mhello world'}
  </Ansi>;
};
```

Will render:

```javascript
<code>
  <span style="color:rgb(0, 0, 187)">hello world</span>
</code>
```

### Classes

Style with classes instead of `style` attribute.

```javascript
<Ansi useClasses>{"\u001b[34mhello world"}</Ansi>
```

Will render

```javascript
<code>
  <span class="ansi-blue-fg">hello world</span>
</code>
```

#### Class Names

| Font color             | Background Color |
| ---------------------- | ---------------- |
| ansi-black-fg          | ansi-black-bg    |
| ansi-red-fg            | ansi-red-bg      |
| ansi-green-fg          | ansi-green-bg    |
| ansi-yellow-fg         | ansi-yellow-bg   |
| ansi-blue-fg           | ansi-blue-bg     |
| ansi-magenta-fg        | ansi-magenta-bg  |
| ansi-cyan-fg           | ansi-cyan-bg     |
| ansi-white-fg          | ansi-white-bg    |
| ansi-bright-black-fg   |
| ansi-bright-red-fg     |
| ansi-bright-green-fg   |
| ansi-bright-yellow-fg  |
| ansi-bright-blue-fg    |
| ansi-bright-magenta-fg |
| ansi-bright-cyan-fg    |
| ansi-bright-white-fg   |

## Development

To develop on this project, fork and clone this repository on your local machine. Before making modifications, install the project's dependencies.

```
$ pnpm install
```

To run the test suite for this project, run:

```
$ pnpm test
```

## Documentation

We're working on adding more documentation for this component. Stay tuned by watching this repository!

## Support

If you experience an issue while using this package or have a feature request, please file an issue on the [issue board](https://github.com/nteract/ansi-to-react/issues),

## License

[BSD-3-Clause](https://choosealicense.com/licenses/bsd-3-clause/)

---
_Source: https://npm.io/package/ansi-to-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
