# terminal-size

> Reliably get the terminal window size (columns & rows)

Latest version **4.0.1** (published 2026-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install terminal-size
pnpm add terminal-size
yarn add terminal-size
bun add terminal-size
```

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-02-02 |
| First published | 2023-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 149 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | terminal, size, console, window, width, height, columns, rows, lines, tty, redirected |

## Links

- npm: https://www.npmjs.com/package/terminal-size
- Repository: https://github.com/sindresorhus/terminal-size
- Homepage: https://github.com/sindresorhus/terminal-size#readme
- Issues: https://github.com/sindresorhus/terminal-size/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/terminal-size

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2026-02-02
- 4.0.0 — 2023-11-04

## README

# terminal-size

> Reliably get the terminal window size

Because [`process.stdout.columns`](https://nodejs.org/api/tty.html#tty_writestream_columns) doesn't exist when run [non-interactively](http://www.tldp.org/LDP/abs/html/intandnonint.html), for example, in a child process or when piped. This module even works when all the TTY file descriptors are redirected!

Confirmed working on macOS, Linux, and Windows.

## Install

```sh
npm install terminal-size
```

## Usage

```js
import terminalSize from 'terminal-size';

terminalSize();
//=> {columns: 143, rows: 24}
```

## API

### terminalSize()

Returns an `object` with `columns` and `rows` properties.

## Related

- [terminal-size-cli](https://github.com/sindresorhus/terminal-size-cli) - CLI for this module

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