text-table vs cli-table3 vs table vs cli-table vs console-table-printer
Node.js Table Formatting Libraries Comparison
1 Year
text-tablecli-table3tablecli-tableconsole-table-printerSimilar Packages:
What's Node.js Table Formatting Libraries?

These libraries are designed to create and format tables in the command-line interface (CLI) for Node.js applications. They allow developers to display data in a structured and visually appealing way, enhancing the readability of output in terminal applications. Each library offers unique features and capabilities, catering to different use cases and preferences in table formatting.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
text-table30,766,439---11 years agoMIT
cli-table313,970,79554446.2 kB228 months agoMIT
table12,975,198915335 kB26a month agoBSD-3-Clause
cli-table2,868,7982,28117.3 kB183 years ago-
console-table-printer294,21617845 kB257 months agoMIT
Feature Comparison: text-table vs cli-table3 vs table vs cli-table vs console-table-printer

Ease of Use

  • text-table:

    text-table is extremely easy to use, focusing on generating plain text tables without any complex configurations. It is ideal for those who want a straightforward solution.

  • cli-table3:

    cli-table3 builds upon the simplicity of cli-table but adds more features while maintaining ease of use. It is still user-friendly, making it accessible for developers of all skill levels.

  • table:

    table is designed for quick and efficient table generation, making it very easy to use with a minimalistic approach. It is perfect for developers who want to get tables up and running quickly.

  • cli-table:

    cli-table provides a very straightforward API that allows developers to create tables with minimal setup. It is designed for quick implementations and is easy to learn for beginners.

  • console-table-printer:

    console-table-printer offers a simple API but includes more options for customization, which may require a slight learning curve. However, it is still relatively easy to use for most developers.

Customization Options

  • text-table:

    text-table is minimalistic and does not provide extensive customization options, focusing instead on generating simple text tables without additional styling.

  • cli-table3:

    cli-table3 offers enhanced customization options, including support for Unicode characters and more flexible column definitions, making it suitable for more complex table layouts.

  • table:

    table offers basic customization options but is primarily focused on performance and simplicity, making it less flexible than some other libraries.

  • cli-table:

    cli-table has limited customization options, focusing mainly on basic table formatting. It allows for some styling but lacks advanced features for customization.

  • console-table-printer:

    console-table-printer excels in customization, allowing developers to define colors, styles, and widths for columns, providing a rich visual output for CLI applications.

Performance

  • text-table:

    text-table is lightweight and performs well for generating simple text tables, making it suitable for applications that require minimal processing.

  • cli-table3:

    cli-table3 maintains good performance while adding more features. It is optimized for modern usage and handles Unicode characters efficiently.

  • table:

    table is designed for high performance and is very efficient in generating tables, making it a great choice for applications that need to display large amounts of data quickly.

  • cli-table:

    cli-table is lightweight and performs well for basic table generation, making it suitable for applications that require quick output without heavy processing.

  • console-table-printer:

    console-table-printer may have slightly more overhead due to its advanced features, but it is still efficient for most use cases and provides a visually appealing output.

Output Formatting

  • text-table:

    text-table generates plain text tables that are easy to read but lack advanced formatting options, making it suitable for simple use cases.

  • cli-table3:

    cli-table3 enhances output formatting with better support for Unicode, allowing for more visually appealing tables that can include various character sets.

  • table:

    table focuses on straightforward output formatting, providing clear and concise tables without extensive styling options.

  • cli-table:

    cli-table formats tables in a traditional style, which may be limited in terms of aesthetics but is functional for basic needs.

  • console-table-printer:

    console-table-printer provides rich output formatting options, including colors and styles, making it ideal for applications that require a more polished presentation.

Community and Maintenance

  • text-table:

    text-table is a mature library that is stable and well-maintained, but it may not see frequent updates due to its straightforward nature.

  • cli-table3:

    cli-table3 is actively maintained and has a growing community, providing regular updates and improvements over its predecessor.

  • table:

    table is maintained with a focus on performance and simplicity, ensuring that it remains a reliable choice for developers.

  • cli-table:

    cli-table has a stable user base and is well-maintained, although it may not receive frequent updates due to its simplicity.

  • console-table-printer:

    console-table-printer is actively developed with a focus on adding new features and enhancements, supported by a responsive community.

How to Choose: text-table vs cli-table3 vs table vs cli-table vs console-table-printer
  • text-table:

    Choose text-table if you prefer a library that focuses on simplicity and ease of use for generating plain text tables. It is ideal for projects that require basic table formatting without additional complexity.

  • cli-table3:

    Select cli-table3 if you require a modernized version of cli-table with additional features and better support for Unicode characters. It is ideal for projects that need more flexibility and customization in table styling.

  • table:

    Use table if you need a lightweight and efficient solution for generating tables with minimal configuration. It is suitable for quick implementations where performance is a priority.

  • cli-table:

    Choose cli-table if you need a simple and straightforward solution for creating tables in the CLI. It is easy to use and suitable for basic table formatting without advanced features.

  • console-table-printer:

    Opt for console-table-printer if you want a library that supports advanced features like colorized output and customizable column widths. It is perfect for applications that need enhanced visual representation of data in tables.

README for text-table

text-table

generate borderless text table strings suitable for printing to stdout

build status

browser support

example

default align

var table = require('text-table');
var t = table([
    [ 'master', '0123456789abcdef' ],
    [ 'staging', 'fedcba9876543210' ]
]);
console.log(t);
master   0123456789abcdef
staging  fedcba9876543210

left-right align

var table = require('text-table');
var t = table([
    [ 'beep', '1024' ],
    [ 'boop', '33450' ],
    [ 'foo', '1006' ],
    [ 'bar', '45' ]
], { align: [ 'l', 'r' ] });
console.log(t);
beep   1024
boop  33450
foo    1006
bar      45

dotted align

var table = require('text-table');
var t = table([
    [ 'beep', '1024' ],
    [ 'boop', '334.212' ],
    [ 'foo', '1006' ],
    [ 'bar', '45.6' ],
    [ 'baz', '123.' ]
], { align: [ 'l', '.' ] });
console.log(t);
beep  1024
boop   334.212
foo   1006
bar     45.6
baz    123.

centered

var table = require('text-table');
var t = table([
    [ 'beep', '1024', 'xyz' ],
    [ 'boop', '3388450', 'tuv' ],
    [ 'foo', '10106', 'qrstuv' ],
    [ 'bar', '45', 'lmno' ]
], { align: [ 'l', 'c', 'l' ] });
console.log(t);
beep    1024   xyz
boop  3388450  tuv
foo    10106   qrstuv
bar      45    lmno

methods

var table = require('text-table')

var s = table(rows, opts={})

Return a formatted table string s from an array of rows and some options opts.

rows should be an array of arrays containing strings, numbers, or other printable values.

options can be:

  • opts.hsep - separator to use between columns, default ' '
  • opts.align - array of alignment types for each column, default ['l','l',...]
  • opts.stringLength - callback function to use when calculating the string length

alignment types are:

  • 'l' - left
  • 'r' - right
  • 'c' - center
  • '.' - decimal

install

With npm do:

npm install text-table

Use with ANSI-colors

Since the string length of ANSI color schemes does not equal the length JavaScript sees internally it is necessary to pass the a custom string length calculator during the main function call.

See the test/ansi-colors.js file for an example.

license

MIT