cli-table-lite
v1.0.0
Published
Minimalist, zero-dependency ASCII and Unicode table renderer for terminal output, logs, and CLI dashboards.
Maintainers
Readme
📊 cli-table-lite
Minimalist, zero-dependency ASCII and Unicode table formatter for Node.js CLI tools, terminal dashboards, and markdown reports.
💡 Why cli-table-lite?
Popular CLI table libraries like cli-table3 or table often weigh heavily (hundreds of kilobytes of string-width and east-asian-width dependencies).
cli-table-lite is focused on pure speed and zero overhead:
- ⚡ Zero Dependencies — Less than 1.5 KB minified with zero external dependencies.
- 📐 Multiple Visual Styles — Seamlessly switch between Unicode Box Drawing, clean ASCII, GitHub Markdown, and Compact spacing.
- 🎯 Alignment & Padding — Precise
left,center, andrightalignment controls with customizable cell padding. - 🏷️ Dynamic Column Inference — Pass an array of objects directly and headers/widths calculate automatically.
- 📦 Dual ESM & CommonJS — Native compatibility across Node.js, Next.js, Vite, Bun, and Deno.
📥 Installation
# npm
npm install cli-table-lite
# pnpm
pnpm add cli-table-lite
# yarn
yarn add cli-table-lite
# bun
bun add cli-table-lite🚀 Usage & Real-World Examples
1. Basic Box Table
import { renderTable } from 'cli-table-lite';
const data = [
{ id: 1, name: 'Alice Doe', role: 'Lead Architect', status: 'Active' },
{ id: 2, name: 'Bob Smith', role: 'Frontend Engineer', status: 'Active' },
{ id: 3, name: 'Charlie', role: 'QA Analyst', status: 'Offline' },
];
console.log(renderTable(data));Output:
┌────┬───────────┬───────────────────┬─────────┐
│ id │ name │ role │ status │
├────┼───────────┼───────────────────┼─────────┤
│ 1 │ Alice Doe │ Lead Architect │ Active │
│ 2 │ Bob Smith │ Frontend Engineer │ Active │
│ 3 │ Charlie │ QA Analyst │ Offline │
└────┴───────────┴───────────────────┴─────────┘2. GitHub Markdown Table Mode
Generate formatted Markdown tables for GitHub PR comments, issue descriptions, or automated CI docs:
import { renderTable } from 'cli-table-lite';
const stats = [
{ package: 'auth-service', size: '12 KB', coverage: '98%' },
{ package: 'api-gateway', size: '45 KB', coverage: '94%' },
];
const mdTable = renderTable(stats, { borderStyle: 'markdown' });
console.log(mdTable);Output:
| package | size | coverage |
|--------------|-------|----------|
| auth-service | 12 KB | 98% |
| api-gateway | 45 KB | 94% |3. Custom Columns & Alignment
import { renderTable } from 'cli-table-lite';
const sales = [
{ item: 'MacBook Pro', price: '$2,499', qty: 5 },
{ item: 'Dell XPS 15', price: '$1,899', qty: 12 },
{ item: 'Magic Mouse', price: '$79', qty: 45 },
];
const output = renderTable(sales, {
columns: [
{ key: 'item', header: 'Product Name', align: 'left' },
{ key: 'price', header: 'Unit Price', align: 'right' },
{ key: 'qty', header: 'Stock', align: 'center' },
],
padding: 2,
});
console.log(output);📖 API Reference
renderTable(data, options?)
- Parameters:
data(Record<string, any>[]): Array of plain objects.options(TableOptions, optional): Formatting options.
- Returns:
stringcontaining the multi-line rendered table.
Options (TableOptions):
| Property | Type | Default | Description |
|---|---|---|---|
| borderStyle | 'box' \| 'ascii' \| 'markdown' \| 'compact' | 'box' | Border style preset |
| padding | number | 1' | Number of horizontal spaces around cell content |
| columns | (string \| TableColumn)[] | Inferred | Custom column list, ordering, and alignments |
Column Definition (TableColumn):
| Property | Type | Default | Description |
|---|---|---|---|
| key | string | Required | Property key in data objects |
| header | string | key | Header text to display in top row |
| align | 'left' \| 'center' \| 'right' | 'left' | Column text alignment |
| width | number | Auto | Minimum column width |
💖 Support the Project
If cli-table-lite helps keep your terminal outputs and dashboards neat, please support ongoing development:
👉 Sponsor @Piratha97 on GitHub Sponsors
📄 License
MIT © 2026 Pirapaakaran Pirathapan
