cli-table3

Pretty unicode tables for the command line, drop-in API-compatible with the original cli-table

Library
npm
v0.6.5
635 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
41 /100 Fair
Development Activity 8
Maintenance 20
Community 48
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
64 /100 Good
Architecture 62
Code Quality 68
Innovation 55
Learning Curve 70

cli-table3 renders unicode-aided tables for Node.js command-line scripts, letting you print aligned, bordered, and colorized tabular data straight to a terminal. It is a maintained continuation of the original cli-table and cli-table2 packages, preserving full API compatibility while adding cell/row spanning, vertical alignment, word wrapping, and more robust handling of ANSI color codes inside cells.

Because the table itself is just an Array subclass, building one feels like ordinary JavaScript: push rows, splice them, or unshift a new one, then call .toString() to get terminal-ready output. Horizontal, vertical, and cross-tables are all supported out of the box, and custom border characters or per-cell styling let you match any CLI’s visual style.

What You Get

  • Horizontal, vertical, and cross-table layouts from the same API
  • Column and row spanning for merged cells
  • Per-cell styling: border characters, colors, and padding
  • Vertical alignment (top, bottom, center) and word wrapping on word boundaries
  • Truncation of cell text that safely accounts for embedded ANSI color codes
  • Full backwards compatibility with the original cli-table API

Common Use Cases

  • Printing command output (npm/yarn-style dependency lists, status reports) as aligned tables
  • Building admin/debug CLIs that need to display database rows or API responses legibly
  • Rendering comparison or summary tables in build/test tool output
  • Adding colorized, bordered output to internal developer tooling scripts

Under The Hood

Architecture - The table itself (src/table.js) extends the native Array, so pushing/splicing rows is just array manipulation; rendering runs through a LayoutManager (src/layout-manager.js) that computes column widths, resolves row/col spans, and merges border characters, before handing each cell to Cell (src/cell.js) for width-aware wrapping, padding, and truncation, and finally joining rows into the printed string. Tech Stack - Plain CommonJS JavaScript with two runtime dependencies: ansis for ANSI color styling and string-width for correct-width Unicode/wide-character measurement; builds and lints via ESLint, Prettier, and a Jest test/lint runner, with Yarn as the package manager. Code Quality - The test/ directory carries the full original cli-table test suite (original-cli-table-index-tests.js) plus dedicated suites per feature (colors, layout, cells, utils), giving strong regression coverage for a project of this size; code favors small, single-purpose modules over abstraction layers. API Design - The Array-subclass model keeps the day-to-day API tiny (new Table(opts), .push(), .toString()), which combined with strict backward compatibility with the original cli-table means most consumers reach working output within a few lines and existing cli-table users can drop it in without code changes.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers