cli-table3 vs table vs cli-table vs blessed vs ascii-table
Node.js Command Line Table Libraries Comparison
1 Year
cli-table3tablecli-tableblessedascii-tableSimilar Packages:
What's Node.js Command Line Table Libraries?

These libraries provide various functionalities for displaying data in a tabular format within the command line interface (CLI). They allow developers to create visually appealing and structured outputs that enhance the readability of data presented in terminal applications. Each library has its own unique features, styles, and capabilities, catering to different needs for formatting and displaying tables in Node.js applications.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
cli-table313,378,08654546.2 kB228 months agoMIT
table13,012,118915335 kB26a month agoBSD-3-Clause
cli-table2,847,7142,28317.3 kB183 years ago-
blessed1,384,83811,399-2569 years agoMIT
ascii-table156,185184-239 years agoMIT
Feature Comparison: cli-table3 vs table vs cli-table vs blessed vs ascii-table

Rendering Style

  • cli-table3:

    cli-table3 enhances rendering capabilities with support for row spanning and improved styling options, providing a modern approach to table display in the CLI.

  • table:

    table supports both ASCII and Unicode rendering, allowing for flexible table designs that can accommodate various character sets and styles.

  • cli-table:

    cli-table supports basic ASCII rendering with customizable styles, allowing developers to define borders, padding, and alignment for a clean presentation of tabular data.

  • blessed:

    blessed provides a rich rendering style with support for colors, borders, and various UI components, allowing for more visually appealing tables and interfaces in terminal applications.

  • ascii-table:

    ascii-table offers a straightforward ASCII rendering style, making it easy to display tables in a simple text format. It is perfect for quick outputs without any additional styling requirements.

Complexity and Features

  • cli-table3:

    cli-table3 builds on cli-table with additional features such as row spanning and better performance, making it a more robust choice for applications that require advanced table functionalities.

  • table:

    table provides a versatile set of features, including support for different data types and advanced formatting options, making it suitable for applications that need flexibility in table presentation.

  • cli-table:

    cli-table offers a balance of simplicity and functionality, providing essential features for table formatting without overwhelming complexity, making it easy to integrate into projects.

  • blessed:

    blessed is a more complex library that includes a wide range of features beyond table rendering, such as input handling and window management, making it suitable for comprehensive terminal applications.

  • ascii-table:

    ascii-table is simple and lightweight, focusing on basic table generation without complex features. It is ideal for quick implementations where advanced functionality is not necessary.

Maintenance and Community Support

  • cli-table3:

    cli-table3 is actively maintained and has a growing community, making it a good choice for developers looking for a modern alternative to cli-table.

  • table:

    table is well-maintained and has a supportive community, ensuring that it receives regular updates and enhancements.

  • cli-table:

    cli-table is widely used and has a solid community, though it may not receive as many updates as newer libraries. It remains a reliable choice for basic table needs.

  • blessed:

    blessed has a strong community and is actively maintained, ensuring that it stays up-to-date with the latest features and improvements for terminal applications.

  • ascii-table:

    ascii-table is lightweight and has a smaller community, which may result in less frequent updates and support compared to larger libraries.

Learning Curve

  • cli-table3:

    cli-table3 is similar to cli-table in terms of learning curve, but its additional features may require some time to fully grasp and utilize effectively.

  • table:

    table has a moderate learning curve, with a balance of features that are easy to understand while also offering advanced options for those who need them.

  • cli-table:

    cli-table is relatively easy to learn, with straightforward documentation and examples that help developers implement it quickly in their projects.

  • blessed:

    blessed has a steeper learning curve due to its comprehensive feature set and capabilities, which may require more time to understand and utilize effectively.

  • ascii-table:

    ascii-table has a very low learning curve, making it easy for developers to get started quickly without extensive documentation or setup.

Usage Scenario

  • cli-table3:

    cli-table3 is perfect for applications that require more advanced table features, such as row spanning, while still maintaining ease of use.

  • table:

    table is versatile and can be used in a variety of scenarios where both ASCII and Unicode table rendering is needed, making it suitable for diverse applications.

  • cli-table:

    cli-table works well for standard CLI applications that need basic table formatting, making it a go-to choice for many developers.

  • blessed:

    blessed is ideal for building complex terminal applications that require interactive components and advanced UI features, making it suitable for larger projects.

  • ascii-table:

    ascii-table is best suited for simple command-line applications where quick and basic table outputs are needed without additional complexity.

How to Choose: cli-table3 vs table vs cli-table vs blessed vs ascii-table
  • cli-table3:

    Use cli-table3 if you require a more modern and actively maintained version of cli-table with additional features such as row spanning and improved performance. It is perfect for applications that need enhanced table capabilities without sacrificing ease of use.

  • table:

    Choose table if you need a flexible library that supports both ASCII and Unicode table rendering. It is suitable for applications that require more advanced formatting options and the ability to handle various data types.

  • cli-table:

    Select cli-table for a classic and widely-used solution that supports basic table formatting with customizable styles. It is a good choice for projects that need a balance between simplicity and functionality.

  • blessed:

    Opt for blessed if you are looking for a comprehensive library that not only supports table rendering but also provides a full suite of terminal UI components. It is suitable for building more complex CLI applications with interactive features.

  • ascii-table:

    Choose ascii-table if you need a simple and lightweight solution for generating ASCII tables with minimal dependencies. It is straightforward to use and ideal for quick implementations where advanced features are not required.

README for cli-table3

cli-table3

npm version Build Status

This utility allows you to render unicode-aided tables on the command line from your node.js scripts.

cli-table3 is based on (and api compatible with) the original cli-table, and cli-table2, which are both unmaintained. cli-table3 includes all the additional features from cli-table2.

Screenshot

Features not in the original cli-table

  • Ability to make cells span columns and/or rows.
  • Ability to set custom styles per cell (border characters/colors, padding, etc).
  • Vertical alignment (top, bottom, center).
  • Word wrapping options.
  • More robust truncation of cell text that contains ansi color characters.
  • Better handling of text color that spans multiple lines.
  • API compatible with the original cli-table.
  • Exhaustive test suite including the entire original cli-table test suite.
  • Lots of examples auto-generated from the tests (basic, advanced).

Features

  • Customizable characters that constitute the table.
  • Color/background styling in the header through colors.js @colors/colors
  • Column width customization
  • Text truncation based on predefined widths
  • Text alignment (left, right, center)
  • Padding (left, right)
  • Easy-to-use API

Installation

npm install cli-table3

How to use

A portion of the unit test suite is used to generate examples:

  • basic-usage - covers basic uses.
  • advanced - covers using the new column and row span features.

This package is api compatible with the original cli-table. So all the original documentation still applies (copied below).

Horizontal Tables

var Table = require('cli-table3');

// instantiate
var table = new Table({
    head: ['TH 1 label', 'TH 2 label']
  , colWidths: [100, 200]
});

// table is an Array, so you can `push`, `unshift`, `splice` and friends
table.push(
    ['First value', 'Second value']
  , ['First value', 'Second value']
);

console.log(table.toString());

Vertical Tables

var Table = require('cli-table3');
var table = new Table();

table.push(
    { 'Some key': 'Some value' }
  , { 'Another key': 'Another value' }
);

console.log(table.toString());

Cross Tables

Cross tables are very similar to vertical tables, with two key differences:

  1. They require a head setting when instantiated that has an empty string as the first header
  2. The individual rows take the general form of { "Header": ["Row", "Values"] }
var Table = require('cli-table3');
var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] });

table.push(
    { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] }
  , { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] }
);

console.log(table.toString());

Custom styles

The chars property controls how the table is drawn:

var table = new Table({
  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': '│' }
});

table.push(
    ['foo', 'bar', 'baz']
  , ['frob', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs:
//
//╔══════╤═════╤══════╗
//║ foo  │ bar │ baz  ║
//╟──────┼─────┼──────╢
//║ frob │ bar │ quuz ║
//╚══════╧═════╧══════╝

Empty decoration lines will be skipped, to avoid vertical separator rows just set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string:

var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} });
table.push(
    ['foo', 'bar', 'baz']
  , ['frobnicate', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs: (note the lack of the horizontal line between rows)
//┌────────────┬─────┬──────┐
//│ foo        │ bar │ baz  │
//│ frobnicate │ bar │ quuz │
//└────────────┴─────┴──────┘

By setting all chars to empty with the exception of 'middle' being set to a single space and by setting padding to zero, it's possible to get the most compact layout with no decorations:

var table = new Table({
  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': ' ' },
  style: { 'padding-left': 0, 'padding-right': 0 }
});

table.push(
    ['foo', 'bar', 'baz']
  , ['frobnicate', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs:
//foo        bar baz
//frobnicate bar quuz

Debugging

Later versions of cli-table3 supporting debugging your table data.

Enable and use debugging:

var table = new Table({ debug: 1 });
table.push([{}, {},}); // etc.

console.log(table.toString());
table.messages.forEach((message) => console.log(message));

If you are rendering multiple tables with debugging on run Table.reset() after rendering each table.

Build Targets

Clone the repository and run yarn install to install all its submodules, then run one of the following commands:

Run the tests with coverage reports.
$ yarn test:coverage
Run the tests every time a file changes.
$ yarn test:watch
Update the documentation.
$ yarn docs

Credits

  • James Talmage - author <james.talmage@jrtechnical.com> (jamestalmage)
  • Guillermo Rauch - author of the original cli-table <guillermo@learnboost.com> (Rauchg)

License

(The MIT License)

Copyright (c) 2014 James Talmage <james.talmage@jrtechnical.com>

Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <dev@learnboost.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.