CLI Simple Table

1.1.1 · active · verified Wed Apr 22

cli-simple-table is a lightweight utility for generating basic, unstyled ASCII tables in command-line interfaces. Its design prioritizes simplicity and a minimal API, making it suitable for quick console output without extensive configuration. The library allows users to define table headers, add rows, and configure column-specific options such as text alignment and maximum width for truncation. It provides a `toString()` method to render the table for printing. The current stable version is `1.1.1`, released in late 2021, indicating a moderate release cadence. It differentiates itself from more feature-rich table rendering libraries by offering a focused solution for common CLI display needs. The package ships with TypeScript types, ensuring good developer experience for TypeScript projects, and supports both CommonJS and ES Module environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic table creation with headers and rows, including colored text using an external library like `chalk`.

import SimpleTable from 'cli-simple-table';
import chalk from 'chalk'; // chalk is an external dependency

const table = new SimpleTable();

table.header('Name', 'Emoji');

table.row(chalk.red('Squid'), '🦑');
table.row(chalk.green('Frog'), '🐸');
table.row(chalk.yellow('Tiger'), '🐯');
table.row(chalk.blue('Whale'), '🐳');
table.row(chalk.magenta('Unicorn'), '🦄');
table.row(chalk.cyan('Dolphin'), '🐬');
table.row(chalk.white('Panda'), '🐼');

console.log(table.toString());

view raw JSON →