CLI Table Generator

0.3.11 · maintenance · verified Wed Apr 22

cli-table is a Node.js utility for rendering structured, unicode-aided tables directly in the command line interface. As of its latest version 0.3.11, last published approximately four years ago, it provides extensive customization options including configurable characters for borders, adjustable column widths, text truncation, alignment (left, right, center), and padding. It also supports styling table headers through integration with the `colors.js` library. While its version number (0.3.x) and infrequent updates suggest it's a stable but not actively developed project, it remains a popular choice for producing visually organized output in CLI applications, evidenced by over 2.6 million weekly downloads. Its primary differentiator is its granular control over table aesthetics, allowing developers to create highly tailored visual presentations beyond simple CSV-like output.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create both a horizontal and a vertical unicode table with custom headers, column widths, and character styles, then populate and print them to the console.

const Table = require('cli-table');

// Instantiate a new table with custom headers and column widths
const table = new Table({
    head: ['Task ID', 'Description', 'Status', 'Due Date']
  , colWidths: [10, 40, 15, 20] // Define column widths
  , chars: {
        'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗'
      , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝'
      , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼'
      , 'right': '║' , 'right-mid': '╢' , 'middle': '│'
    }
});

// Add rows to the table. Table is an Array-like object.
table.push(
    [1, 'Implement feature A', 'In Progress', '2026-05-01']
  , [2, 'Fix bug in module B that causes a critical error', 'Blocked', '2026-04-28']
  , [3, 'Review pull request #123', 'Pending', '2026-04-25']
);

// Log the table to the console
console.log(table.toString());

// Example of a vertical table
const verticalTable = new Table();
verticalTable.push(
    { 'User': 'Alice' }
  , { 'Role': 'Admin' }
  , { 'Last Login': '2026-04-22 10:30' }
);
console.log('\nVertical Table:');
console.log(verticalTable.toString());

view raw JSON →