# term-size

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

Latest version **4.0.0** (published 2023-11-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-11-04 |
| First published | 2016-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 49 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/term-size
- Repository: https://github.com/sindresorhus/term-size
- Homepage: https://github.com/sindresorhus/term-size#readme
- Issues: https://github.com/sindresorhus/term-size/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/term-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.0 (latest) — 2023-11-04
- 3.0.2 — 2022-05-24
- 3.0.1 — 2021-10-07
- 3.0.0 — 2021-08-18
- 2.2.1 — 2020-10-25
- 2.2.0 — 2020-01-30
- 2.1.1 — 2019-12-18
- 2.1.0 — 2019-05-25
- 2.0.0 — 2019-04-28
- 1.2.0 — 2017-06-26
- 1.1.0 — 2017-05-07
- 1.0.0 — 2017-05-06
- 0.1.1 — 2017-02-03
- 0.1.0 — 2016-09-09

## README

# term-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

```
$ npm install term-size
```

## Usage

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

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

## API

### terminalSize()

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

## Info

The bundled macOS binary is signed and hardened.

## Related

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

---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-term-size?utm_source=npm-term-size&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

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