# @visulima/is-ansi-color-supported

> Detect whether a terminal or browser supports ansi colors.

Latest version **5.0.0** (published 2026-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @visulima/is-ansi-color-supported
pnpm add @visulima/is-ansi-color-supported
yarn add @visulima/is-ansi-color-supported
bun add @visulima/is-ansi-color-supported
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-10-15 |
| First published | 2024-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^22.14.0 \|\| >=24.10.0 |
| Dependencies | 0 |
| Unpacked size | 75.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 58 |
| Author | Daniel Bannert |
| Maintainers | prisis |
| Keywords | 256, FORCE_COLOR, NO_COLOR, anolilab, ansi, ansi-colors, capability, cli, color, colorize, colors, colour, command-line, console, detect, edge, next.js, nextjs, shell, style, styles, support, supports, terminal, truecolor, tty, visulima, xterm |

## Links

- npm: https://www.npmjs.com/package/@visulima/is-ansi-color-supported
- Repository: https://github.com/visulima/visulima
- Homepage: https://visulima.com/packages/is-ansi-color-supported/
- Issues: https://github.com/visulima/visulima/issues
- Funding: https://github.com/sponsors/prisis
- npm.io page: https://npm.io/package/@visulima/is-ansi-color-supported

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2026-10-15
- 3.0.0-alpha.14 (alpha) — 2026-06-30
- 4.0.0 — 2026-08-08
- 3.1.0 — 2026-08-02
- 3.0.1 — 2026-07-26
- 3.0.0 — 2026-07-03
- 3.0.0-alpha.13 — 2026-06-13
- 3.0.0-alpha.12 — 2026-06-04
- 3.0.0-alpha.11 — 2026-05-27
- 3.0.0-alpha.10 — 2026-04-22
- 3.0.0-alpha.9 — 2026-04-15
- 3.0.0-alpha.8 — 2026-04-08
- 3.0.0-alpha.7 — 2026-03-26
- 3.0.0-alpha.6 — 2026-03-26
- 3.0.0-alpha.5 — 2026-03-06
- … 32 more at https://npm.io/package/@visulima/is-ansi-color-supported/versions

## README

<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->

<a href="https://www.anolilab.com/open-source" align="center">

  <img src="__assets__/package-og.svg" alt="is-ansi-color-supported" />

</a>

<h3 align="center">Detect whether a terminal or browser supports ansi colors.</h3>

<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->

<br />

<div align="center">

[![typescript-image][typescript-badge]][typescript-url]
[![mit licence][license-badge]][license]
[![npm downloads][npm-downloads-badge]][npm-downloads]
[![Chat][chat-badge]][chat]
[![PRs Welcome][prs-welcome-badge]][prs-welcome]

</div>

---

<div align="center">
    <p>
        <sup>
            Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
        </sup>
    </p>
</div>

---

## Install

```sh
npm install @visulima/is-ansi-color-supported
```

```sh
yarn add @visulima/is-ansi-color-supported
```

```sh
pnpm add @visulima/is-ansi-color-supported
```

## Usage

```typescript
import { isStdoutColorSupported, isStderrColorSupported } from "@visulima/is-ansi-color-supported";

/**
 * Levels:
 * - `0` - All colors disabled.
 * - `1` - Basic 16 colors support.
 * - `2` - ANSI 256 colors support.
 * - `3` - Truecolor 16 million colors support.
 */
console.log(isStdoutColorSupported()); // 3

console.log(isStderrColorSupported()); // 3
```

### Custom detection (`createIsColorSupported`)

For library authors who need more control, `createIsColorSupported` lets you pick the
stream, disable CLI flag sniffing, or force the TTY state:

```typescript
import { createIsColorSupported } from "@visulima/is-ansi-color-supported";

// Detect stdout color support without inspecting `process.argv`
// (useful when your CLI defines its own `--color` semantics):
const level = createIsColorSupported("stdout", { sniffFlags: false });

// Probe stderr while forcing the TTY state (e.g. when writing to a log file):
const stderrLevel = createIsColorSupported("stderr", { isTTY: false });
```

> The `browser` and `edge-light` builds also export `createIsColorSupported` for API
> parity, but ignore the `stream`/`options` arguments (those runtimes have no streams,
> CLI args, `tty`, or `os`).

## Color support

This package automatically detects the supported color space:

- TrueColor
- ANSI 256 colors
- ANSI 16 colors
- black & white (no color)

There is no standard way to detect which color space is supported.
The most common way to detect color support is to check the `TERM` and `COLORTERM` environment variables.
CI systems can be detected by checking for the existence of the `CI` and other specifically environment variables.
Combine that with the knowledge about which operating system the program is running on, and we have a decent enough way to detect colors.

| Terminal                         | ANSI 16<br>colors | ANSI 256<br>colors | True<br>Color |  env.<br>TERM  | env.<br>COLORTERM | Specifically ENV variables             |
| :------------------------------- | ----------------- | :----------------- | :------------ | :------------: | :---------------: | :------------------------------------- |
| Azure CI                         | ✅                | ❌                 | ❌            |      dumb      |                   | TF_BUILD<br>AGENT_NAME                 |
| GitHub CI                        | ✅                | ✅                 | ✅            |      dumb      |                   | CI<br>GITHUB_ACTIONS                   |
| GitTea CI                        | ✅                | ✅                 | ✅            |      dumb      |                   | CI<br>GITEA_ACTIONS                    |
| GitLab CI                        | ✅                | ❌                 | ❌            |      dumb      |                   | CI<br>GITLAB_CI                        |
| Travis CI                        | ✅                | ❌                 | ❌            |      dumb      |                   | TRAVIS                                 |
| PM2<br>not isTTY                 | ✅[^1]            | ✅[^1]             | ✅[^1]        |      dumb      |                   | PM2_HOME<br>pm_id                      |
| JetBrains TeamCity<br>>=2020.1.1 | ✅                | ✅                 | ❌            |                |                   | TEAMCITY_VERSION                       |
| JetBrains IDEA                   | ✅                | ✅                 | ✅            | xterm-256color |                   | TERMINAL_EMULATOR='JetBrains-JediTerm' |
| VS Code                          | ✅                | ✅                 | ✅            | xterm-256color |     truecolor     |                                        |
| Windows<br>Terminal              | ✅                | ✅                 | ✅[^2]        |                |                   |                                        |
| Windows<br>PowerShell            | ✅                | ✅                 | ✅[^2]        |                |                   |                                        |
| macOS Terminal                   | ✅                | ✅                 | ❌            | xterm-256color |                   |                                        |
| iTerm                            | ✅                | ✅                 | ✅            | xterm-256color |     truecolor     |                                        |
| Terminal emulator Kitty          | ✅                | ✅                 | ✅            |  xterm-kitty   |                   |                                        |

[^1]: Colors supported depends on actual terminal.

[^2]: The Windows terminal supports true color since Windows 10 revision 14931 (2016-09-21).

See also:

- [Truecolor Support in Output Devices](https://github.com/termstandard/colors#truecolor-support-in-output-devices).
- [So you want to render colors in your terminal](https://marvinh.dev/blog/terminal-colors/).

## Environment variables

To force disable or enable colored output use environment variables `NO_COLOR` and `FORCE_COLOR`.

The `NO_COLOR` variable should be presents with any not empty value.
The value is not important, e.g., `NO_COLOR=1` `NO_COLOR=true` disable colors.
See standard description by [NO_COLOR](https://no-color.org/).

The `FORCE_COLOR` variable should be presents with one of values:\
`FORCE_COLOR=0` (or `FORCE_COLOR=false`) force disable colors\
`FORCE_COLOR=1`, `2`, `3` (or `FORCE_COLOR=true`) force enable colors at the given level

When `FORCE_COLOR` requests color (any value other than `0`/`false`) it takes precedence over the
`NO_COLOR` environment variable, so `FORCE_COLOR=true NO_COLOR=1` and `FORCE_COLOR=1 NO_COLOR=1` both
enable colors. The `--no-color` CLI flag still wins over everything, since command-line arguments have
the highest priority.

## CLI arguments

Use arguments `--no-color` or `--color=false` to disable colors and `--color` to enable ones.

For example, an executable script _colors.js_:

```js
#!/usr/bin/env node
import { isStdoutColorSupported } from "@visulima/is-ansi-color-supported";

console.log(isStdoutColorSupported());
```

Execute the script in a terminal:

```
$ ./colors.js                        # colored output in terminal
$ ./colors.js --no-color             # non colored output in terminal
$ ./colors.js --color=false          # non colored output in terminal

$ ./colors.js > log.txt              # output in file without ANSI codes
$ ./colors.js --color > log.txt      # output in file with ANSI codes
$ ./colors.js --color=true > log.txt # output in file with ANSI codes
```

> **Warning**
>
> The command line arguments have a higher priority than environment variable.

> **Note**
>
> A 256-color `TERM` (e.g. `TERM=xterm-256color`) reports level `2` even when the output is piped
> to a file and not a TTY. This is intentional (ansis-style behaviour). If you need supports-color's
> stricter TTY-first gating, use `createIsColorSupported("stdout", { isTTY: false })`.

## Info

For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.

Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.

## Related

- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module

## Supported Node.js Versions

Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).

## Contributing

If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.

> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

## Credits

- [Daniel Bannert](https://github.com/prisis)
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)

## Made with ❤️ at Anolilab

This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!

## License

The visulima is-ansi-color-supported is open-sourced software licensed under the [MIT][license]

<!-- badges -->

[license-badge]: https://img.shields.io/npm/l/@visulima/is-ansi-color-supported?style=for-the-badge
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/is-ansi-color-supported?style=for-the-badge
[npm-downloads]: https://www.npmjs.com/package/@visulima/is-ansi-color-supported
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
[chat-badge]: https://img.shields.io/discord/902465130518949899.svg?style=for-the-badge
[chat]: https://discord.gg/eajEZvk2PG
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: https://www.typescriptlang.org/

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