Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Node.js
  3. terminal-size

terminal-size

MITJavaScriptv4.0.1

A Node.js module to reliably get terminal window dimensions, even in non-interactive environments.

GitHubGitHub
149 stars17 forks0 contributors

What is terminal-size?

terminal-size is a Node.js module that reliably retrieves the terminal window dimensions (columns and rows). It solves the problem where Node.js's built-in `process.stdout.columns` and `process.stdout.rows` are unavailable in non-interactive environments, such as child processes or when output is piped.

Target Audience

Node.js developers building CLI tools, scripts, or applications that need to adapt to terminal size in various execution contexts.

Value Proposition

It provides a cross-platform, dependable solution for terminal size detection where native methods fail, ensuring consistent behavior in interactive and non-interactive scenarios.

Overview

Reliably get the terminal window size

Use Cases

Best For

  • Building CLI tools that adjust output based on terminal width
  • Scripts running in child processes that need terminal dimensions
  • Applications with piped or redirected output requiring TTY info
  • Cross-platform Node.js projects needing reliable terminal size detection
  • Tools that dynamically format console output
  • Environments where TTY file descriptors are unavailable

Not Ideal For

  • Projects not using Node.js or requiring terminal size in other programming languages
  • CLI tools that exclusively run in interactive terminals and can rely safely on process.stdout.columns
  • Applications needing real-time terminal resize detection without manual polling

Pros & Cons

Pros

Cross-Platform Reliability

Confirmed to work on macOS, Linux, and Windows as stated in the README, ensuring consistent behavior across operating systems.

Non-Interactive Support

Functions correctly in child processes or when TTY file descriptors are redirected, solving the issue where process.stdout.columns is undefined in such scenarios.

Simple API

Provides a single function call returning an object with columns and rows, making integration straightforward without complex configuration.

Lightweight and Focused

A minimal module dedicated solely to terminal size detection, with no unnecessary dependencies cluttering the project.

Cons

No Real-Time Updates

Only retrieves a static snapshot of terminal size; lacks event-driven methods or polling for handling terminal resizing dynamically.

Limited to Size Only

Exclusively provides columns and rows, missing other terminal properties like color support or cursor position that might be needed for advanced CLI features.

Dependency Overhead

For simple interactive scripts, adding an external module may be unnecessary overhead when native Node.js methods suffice.

Frequently Asked Questions

Quick Stats

Stars149
Forks17
Contributors0
Open Issues2
Last commit7 months ago
CreatedSince 2016

Tags

#tty#cross-platform#node-js#cli-tools#terminal-utilities#process-management#shell-scripts

Built With

N
Node.js

Included in

Node.js65.5k
Auto-fetched 11 hours ago

Related Projects

zxzx

A tool for writing better scripts

Stars45,732
Forks1,293
Last commit25 days ago
InkInk

🌈 React for interactive command-line apps

Stars39,829
Forks1,046
Last commit13 days ago
chalkchalk

🖍 Terminal string styling done right

Stars23,315
Forks1,045
Last commit1 month ago
Inquirer.jsInquirer.js

A collection of common interactive command line user interfaces.

Stars21,624
Forks1,366
Last commit21 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub