Pipe JSON or CSV to tty-table and get a table output to your terminal, import tty-table as a module for your own cli application, or use it in the browser.

Code Quality Rank: L4
Monthly Downloads: 0
Programming language: JavaScript
License: GNU Lesser General Public License v3.0 only
Latest version: v3.0

tty-table alternatives and similar modules

Based on the "Command Line Apps" category

Do you think we are missing an alternative of tty-table or a related project?

Add another 'Command Line Apps' Module


tty-table 甡传打字台

Build Status NPM version

Display your data in a table using a terminal, browser, or browser console.


  • [Terminal](docs/terminal.md):
$ npm install tty-table -g
  • Node Module
$ npm install tty-table
  • Browser
<script src="tty-table.bundle.min.js"></script>
 let Table = require('tty-table');


Terminal (Static)



Terminal (Streaming)

$ node examples/data/fake-stream.js | tty-table --format json --header examples/config/header.js


  • See the built-in help for the terminal version of tty-table with: $ tty-table -h

Browser & Browser Console

  • [examples/browser-example.html](examples/browser-example.html)

Browser Console Example

Working Example in Browser

Note that neither ASCI colors nor default borders are rendered in the browser. An alternative border style, as shown below, should be used by setting the following option:

borderStyle : "dashed"

API Reference



Kind: global class
Note: Available border character sets:

 "none": [
   {v: " ", l: " ", j: " ", h: " ", r: " "},
   {v: " ", l: " ", j: " ", h: " ", r: " "},
   {v: " ", l: " ", j: " ", h: " ", r: " "}
 "solid": [
   {v: "β”‚", l: "β”Œ", j: "┬", h: "─", r: "┐"},
   {v: "β”‚", l: "β”œ", j: "β”Ό", h: "─", r: "─"},
   {v: "β”‚", l: "β””", j: "β”΄", h: "─", r: "β”˜"}
 "dashed": [
   {v: "|", l: "+", j: "+", h: "-", r: "+"},
   {v: "|", l: "+", j: "+", h: "-", r: "+"},
   {v: "|", l: "+", j: "+", h: "-", r: "+"}

Table(header, rows, options)

Param Type Description
header array See example
header.column object Column options
header.column.alias string Alternate header column name
header.column.align string default: "center"
header.column.color string default: terminal default color
header.column.footerAlign string default: "center"
header.column.footerColor string default: terminal default color
header.column.formatter function Runs a callback on each cell value in the parent column
header.column.headerAlign string default: "center"
header.column.headerColor string default: terminal's default color
header.column.marginLeft number default: 0
header.column.marginTop number default: 0
header.column.width string \ number
header.column.paddingBottom number default: 0
header.column.paddingLeft number default: 1
header.column.paddingRight number default: 1
header.column.paddingTop number default: 0
rows array See example
options object Table options
options.borderStyle string default: "solid". options: "solid", "dashed", "none"
options.borderCharacters object See @note
options.borderColor string default: terminal's default color
options.compact boolean default: false Removes horizontal lines when true.
options.defaultErrorValue mixed default: 'ERROR!'
options.defaultValue mixed default: '?'
options.errorOnNull boolean default: false
options.truncate mixed default: false When this property is set to a string, cell contents will be truncated by that string instead of wrapped when they extend beyond of the width of the cell. For example if: "truncate":"..." the cell will be truncated with "..."


let Table = require('tty-table');
let t1 = Table(header,rows,options);

Table.tableObject.render() β‡’ String

Add method to render table to a string

Kind: static method of Table

let str = t1.render(); 
console.log(str); //outputs table


Running tests

$ grunt test

Saving the output of new unit tests

$ grunt st
  • Because:

node script.js --color=always

Dev Tips

  • To generate vim tags (make sure jsctags is installed globally)
$ grunt tags
  • To generate vim tags on file save
$ grunt watch

[Packaging as a distributable](packaging.md)


MIT License

Copyright 2015-2019, Tecfu.

*Note that all licence references and agreements mentioned in the tty-table README section above are relevant to that project's source code only.