# supports-color

> Detect whether a terminal supports color

Latest version **11.0.0** (published 2026-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install supports-color
pnpm add supports-color
yarn add supports-color
bun add supports-color
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 11.0.0 |
| Published | 2026-07-26 |
| First published | 2014-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 371 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | color, colour, colors, terminal, console, cli, ansi, styles, tty, rgb, 256, shell, xterm, command-line, support, supports, capability, detect, truecolor, 16m |

## Links

- npm: https://www.npmjs.com/package/supports-color
- Repository: https://github.com/chalk/supports-color
- Homepage: https://github.com/chalk/supports-color#readme
- Issues: https://github.com/chalk/supports-color/issues
- Funding: https://github.com/chalk/supports-color?sponsor=1
- npm.io page: https://npm.io/package/supports-color

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 11.0.0 (latest) — 2026-07-26
- 10.2.2 — 2025-09-08
- 10.2.0 — 2025-08-17
- 10.1.0 — 2025-08-03
- 10.0.0 — 2024-12-18
- 9.4.0 — 2023-06-28
- 9.3.1 — 2022-12-15
- 9.3.0 — 2022-12-07
- 9.2.3 — 2022-09-07
- 9.2.2 — 2022-03-28
- 9.2.1 — 2021-11-26
- 9.2.0 — 2021-11-26
- 9.1.0 — 2021-11-18
- 9.0.2 — 2021-07-19
- 9.0.1 — 2021-05-29
- … 40 more at https://npm.io/package/supports-color/versions

## README

# supports-color

> Detect whether a terminal supports color

## Install

```sh
npm install supports-color
```

## Usage

```js
import supportsColor from 'supports-color';

if (supportsColor.stdout) {
	console.log('Terminal stdout supports color');
}

if (supportsColor.stdout.has256) {
	console.log('Terminal stdout supports 256 colors');
}

if (supportsColor.stderr.has16m) {
	console.log('Terminal stderr supports 16 million colors (truecolor)');
}
```

## API

Returns an `object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.

The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:

- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
- `.level = 2` and `.has256 = true`: 256 color support
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)

### Custom instance

The package also exposes the named export `createSupportColor` function that takes an arbitrary write stream (for example, `process.stdout`) and an optional options object to (re-)evaluate color support for an arbitrary stream.

```js
import {createSupportsColor} from 'supports-color';

const stdoutSupportsColor = createSupportsColor(process.stdout);

if (stdoutSupportsColor) {
	console.log('Terminal stdout supports color');
}

// `stdoutSupportsColor` is the same as `supportsColor.stdout`
```

The options object supports a single boolean property `sniffFlags`. By default it is `true`, which instructs the detection to sniff `process.argv` for the multitude of `--color` flags (see _Info_ below). If `false`, then `process.argv` is not considered when determining color support.

## Info

It obeys the `--color` and `--no-color` CLI flags.

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. A numeric `FORCE_COLOR` overrides the detected color support and sets the level directly, meaning the terminal cannot raise it to a higher level. Use `FORCE_COLOR=true` to instead only enable color and let the level be detected.

Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively. These take precedence over a non-zero numeric `FORCE_COLOR`.

## Related

- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [supports-hyperlinks](https://github.com/chalk/supports-hyperlinks) - Detect whether a terminal supports hyperlinks
- [supports-terminal-graphics](https://github.com/sindresorhus/supports-terminal-graphics) - Detect which terminal graphics protocols are supported
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
- [is-unicode-supported](https://github.com/sindresorhus/is-unicode-supported) - Detect whether the terminal supports Unicode
- [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive

## Maintainers

- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

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