DEV Community

Arul
Arul

Posted on

I built a standalone CLI table library with Interactive TUI, SQLite, and Sparklines

Every Node.js developer has used cli-table3 or table at some point. They work, but they haven't been updated in years and lack modern features.

I wanted more interactive exploration, built-in analytics, and database browsing, all without pulling in a tree of dependencies. So I built cmd-table.

What is cmd-table?

A modern, TypeScript-first CLI table library for Node.js. It's standalone, lightweight, and packed with features that no other CLI table library offers.

npm install cmd-table
Enter fullscreen mode Exit fullscreen mode

Basic Usage

import { Table } from 'cmd-table';

const table = new Table();
table.addColumn('Name');
table.addColumn('Role');
table.addColumn('Status');

table.addRow({ Name: 'Alice', Role: 'Dev', Status: 'Active' });
table.addRow({ Name: 'Bob', Role: 'PM', Status: 'Offline' });

console.log(table.render());
Enter fullscreen mode Exit fullscreen mode

Output:

╭────────┬──────┬─────────╮
│ Name   │ Role │ Status  │
├────────┼──────┼─────────┤
│ Alice  │ Dev  │ Active  │
│ Bob    │ PM   │ Offline │
╰────────┴──────┴─────────╯
Enter fullscreen mode Exit fullscreen mode

Clean, rounded borders by default. No configuration needed.

What makes it different?

Here's how cmd-table compares to the popular alternatives:

Feature cmd-table cli-table3 table tty-table
Standalone (no deps) Yes No No No
Interactive TUI Yes No No No
SQL / SQLite Yes No No No
Sparklines & Heatmaps Yes No No No
Tree view Yes No No No
Pivot tables Yes No No No
CSV / HTML parser Yes No No No
JSX syntax Yes No No No
Streaming Yes No Yes No
Multiple exports Yes No No No
TypeScript-first Yes Partial Yes No
Actively maintained Yes No No Yes

Let me walk through the features that I'm most excited about.


1. Interactive TUI - Explore Data in Your Terminal

This is the feature I built cmd-table for. Instead of dumping hundreds of rows to stdout, you get a full interactive experience:

import { Table, InteractiveTable } from 'cmd-table';

const table = new Table();
table.addColumn('Name');
table.addColumn('Department');
table.addColumn('Salary');

// ... add hundreds of rows ...

const interactive = new InteractiveTable(table, {
    onSelect: (rows) => {
        console.log('Selected:', rows);
        process.exit(0);
    },
    onExit: () => process.exit(0)
});

interactive.start();
Enter fullscreen mode Exit fullscreen mode

What you get:

  • Right/Left — Page through results
  • s — Sort by column
  • / — Search and filter rows in real-time
  • Space — Select/deselect rows
  • Enter — Confirm selection

No boilerplate. No external TUI framework. Just add your data and call .start().


2. SQL / SQLite Integration

Browse real database tables interactively — with pagination, sorting, and full-text search:

import Database from 'better-sqlite3';
import { Table, AsyncInteractiveTable, SqlDataSource } from 'cmd-table';

const db = new Database('mydata.db');
const source = new SqlDataSource(db, 'employees');

const template = new Table();
template.addColumn('id');
template.addColumn('name');
template.addColumn('department');

const app = new AsyncInteractiveTable(source, template);
await app.start();
db.close();
Enter fullscreen mode Exit fullscreen mode

SqlDataSource handles pagination and search at the SQL level — it doesn't load your entire database into memory.


3. Sparklines & Heatmaps

Visualize trends directly inside table cells:

import { Sparkline, Heatmap } from 'cmd-table';

table.addRow({
    server: 'prod-01',
    cpu: Sparkline.generate([10, 50, 90, 40, 20]),  // ▂▄█▄▂
    health: Heatmap.color(85, 0, 100) + '85%'       // Green text
});

table.addRow({
    server: 'prod-02',
    cpu: Sparkline.generate([80, 85, 90, 95, 99]),   // ▆▇▇██
    health: Heatmap.color(23, 0, 100) + '23%'        // Red text
});
Enter fullscreen mode Exit fullscreen mode

Great for dashboards, monitoring tools, and CI/CD output.


4. Pivot Tables & CrossTabs

Built-in data analysis without importing pandas or lodash:

import { PivotTable, CrossTab } from 'cmd-table';

// Group and aggregate
const pivot = PivotTable.create(salesData, {
    groupBy: 'Region',
    targetColumn: 'Amount',
    algorithm: 'sum'
});

// Matrix view (Sales by Product vs Month)
const matrix = CrossTab.create(salesData, {
    rowKey: 'Product',
    colKey: 'Month',
    valueKey: 'Amount',
    aggregator: 'sum'
});
Enter fullscreen mode Exit fullscreen mode

5. Parse Anything, Export Anywhere

Import from CSV or HTML:

import { CsvTable, HtmlTable } from 'cmd-table';

// CSV string → Table
const table = CsvTable.from('name,age\nAlice,30\nBob,25');

// HTML table → Table
const scraped = HtmlTable.from('<table><tr><td>Data</td></tr></table>');
Enter fullscreen mode Exit fullscreen mode

Export to any format:

const md = table.export('md');    // Markdown
const csv = table.export('csv');  // CSV
const json = table.export('json'); // JSON
Enter fullscreen mode Exit fullscreen mode

6. Tree View

Visualize hierarchical data like file systems or org charts:

const files = [
  { Name: 'src', Size: '-', children: [
    { Name: 'index.ts', Size: '2KB' },
    { Name: 'utils.ts', Size: '1KB' }
  ]},
  { Name: 'package.json', Size: '1KB' }
];

table.addTree('Name', files);
Enter fullscreen mode Exit fullscreen mode

7. CLI Tool

No code needed. Pipe JSON or CSV from the terminal:

# Format JSON
cat data.json | npx cmd-table --columns=name,age --theme=double

# Format CSV
cat data.csv | npx cmd-table

# Interactive explorer
cat large_data.csv | npx cmd-table --interactive
Enter fullscreen mode Exit fullscreen mode

8. Themes

7+ built-in themes. The default is Rounded:

import { Table, THEME_DoubleLine, THEME_Honeywell } from 'cmd-table';

const table = new Table({ theme: THEME_DoubleLine });
Enter fullscreen mode Exit fullscreen mode

Available: Rounded (default), Honeywell, DoubleLine, BoldBox, Dots, Void, and more.


9. JSX Syntax

Define tables declaratively if that's your style:

import { h, render } from 'cmd-table';

const element = (
    <cmd-table theme="doubleHeader">
        <cmd-column name="Task" key="task" />
        <cmd-column name="Status" key="status" />
        <cmd-row task="Deploy" status="Done" />
        <cmd-row task="Test" status="Pending" />
    </cmd-table>
);

console.log(render(element).render());
Enter fullscreen mode Exit fullscreen mode

Getting Started

npm install cmd-table
Enter fullscreen mode Exit fullscreen mode

If you find it useful, a GitHub star goes a long way. Contributions are welcome — check the roadmap for what's planned next.


What features would you want in a CLI table library? Let me know in the comments!

Top comments (0)