npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

console-table-printer

v2.16.1

Published

Printing pretty tables on console log

Downloads

14,458,722

Readme

🖥️🍭 Printing pretty tables in your console

NPM Downloads install size npm version codecov

Synopsis

Print simple tables with colored rows in your console. It's useful when you want to present tables in console output using JS.

Installation

npm install console-table-printer --save

Basic Example

import { printTable } from 'console-table-printer';

// Create a simple task list
const tasks = [
  { id: 1, task: 'Fix login bug', priority: 'High', status: 'In Progress' },
  { id: 2, task: 'Update documentation', priority: 'Medium', status: 'Done' },
  { id: 3, task: 'Add unit tests', priority: 'High', status: 'Todo' },
];

// Print the table
printTable(tasks);

Screenshot

🚨🚨Announcement🚨🚨 Official documentation has moved here

You can also create a Table instance and print it:

import { Table } from 'console-table-printer';

// Create a game leaderboard
const leaderboard = new Table();

// Add players with their scores
leaderboard.addRow({ rank: 1, player: 'Alice', score: 1250, level: 'Master' });
leaderboard.addRow({ rank: 2, player: 'Bob', score: 1180, level: 'Expert' });
leaderboard.addRows([
  { rank: 3, player: 'Charlie', score: 1050, level: 'Advanced' },
  { rank: 4, player: 'Diana', score: 920, level: 'Intermediate' },
]);

// Print the leaderboard
leaderboard.printTable();

Screenshot

You can also add color to your table like this:

import { Table } from 'console-table-printer';

const p = new Table();
p.addRow({ item: 'Pizza', price: 12.99, rating: '5/5' }, { color: 'red' });
p.addRow({ item: 'Burger', price: 8.99, rating: '4/5' }, { color: 'green' });
p.addRow({ item: 'Ramen', price: 15.99, rating: '5/5' }, { color: 'yellow' });
p.addRow({ item: 'Salad', price: 6.99, rating: '3/5' }, { color: 'cyan' });
p.printTable();

Screenshot

You can also configure column properties (color/alignment/title).

import { Table } from 'console-table-printer';

const p = new Table({
  title: 'Project Status',
  columns: [
    { name: 'id', alignment: 'left', color: 'blue' },
    { name: 'project', alignment: 'left' },
    { name: 'status', title: 'Current Status' },
  ],
  colorMap: {
    urgent: '\x1b[31m',
    on_track: '\x1b[32m',
  },
});

p.addRow({ id: 1, project: 'Website Redesign', status: 'On Track' }, { color: 'on_track' });
p.addRow({ id: 2, project: 'Mobile App', status: 'Behind Schedule' }, { color: 'urgent' });
p.addRow({ id: 3, project: 'API Integration', status: 'Completed' }, { color: 'green' });

p.printTable();

Screenshot

CLI

There is also a CLI tool for printing tables directly in the terminal: table-printer-cli

Documentation

Official documentation has moved here: console-table-documentation

Table instance creation

Three ways to create a Table instance:

  1. Simplest way: new Table()

  2. With column names only: new Table(['column1', 'column2', 'column3'])

  3. Detailed table instance creation:

import { Table } from 'console-table-printer';

new Table({
  title: '📊 Sales Report Q4 2024', // Text shown above the table (optional)
  columns: [
    { name: 'region', alignment: 'left', color: 'blue' }, // with alignment and color
    { name: 'sales', alignment: 'right', maxLen: 30 }, // lines bigger than this will be split into multiple lines
    { name: 'growth', title: 'Growth %' }, // Title is shown while printing; by default, title = name
    { name: 'price', transform: (value) => `$${Number(value).toFixed(2)}` }, // Transform function to format cell values before display
  ],
  rows: [
    { region: 'North America', sales: '$2.5M', growth: '+15%' },
    { region: 'Europe', sales: '$1.8M', growth: '+8%' },
    { region: 'Asia Pacific', sales: '$3.2M', growth: '+22%' },
  ],
  sort: (row1, row2) => row2.sales - row1.sales, // sorting order of rows (optional), using the same comparator shape as Array.sort
  filter: (row) => row.growth > '+10%', // filtering rows (optional)
  enabledColumns: ['region', 'sales'], // array of columns that you want to see; all others will be ignored (optional)
  disabledColumns: ['growth'], // array of columns that you don't want to see, these will always be hidden
  colorMap: {
    high_growth: '\x1b[32m', // define a custom color
  },
  charLength: {
    '👋': 2,
    '😅': 2,
  }, // custom character widths in the console
  defaultColumnOptions: {
    alignment: 'center',
    color: 'red',
    maxLen: 40,
    minLen: 20,
  },
});

Functions

  • addRow(rowObject, options) Adds a single row. This can be chained.
  • addRows(rowObjects, options) Adds multiple rows. This accepts an array of row objects. In this case, options will be applied to all rows.
  • clearRows() Removes all rows while keeping the table columns and options. This can be chained.
  • addColumn(columnObject) Adds a single column.
  • addColumns(columnObjects) Adds multiple columns.
  • printTable() Prints the table in your console.

Possible color values for rows

Check docs: color-vals

Example usage: To create a blue row

table.addRow(rowObject, { color: 'blue' });

Example usage: To apply blue to all rows

table.addRows(rowsArray, { color: 'blue' });

Possible alignment values for columns

Check docs: alignment-vals

TypeScript Support

You can get color and alignment as types. Check docs: types-docs

License

MIT