Gathering detailed insights and metrics for tty-table
Gathering detailed insights and metrics for tty-table
Gathering detailed insights and metrics for tty-table
Gathering detailed insights and metrics for tty-table
as-table
A simple function that print objects / arrays as ASCII tables. Handles ANSI styling and weird 💩 Unicode emoji symbols – they won't break the layout.
@tty-pt/types
Automate table and filter creation and other things and have your data models in the client
table-string
Generate nice tables for CLI / console output.
inquirer-table
A table prompt for Inquirer.js.
Terminal table for Windows, Linux, and MacOS. Written in nodejs. Also works in browser console. Word wrap, padding, alignment, colors, Asian character support, per-column callbacks, and you can pass rows as objects or arrays. Backwards compatible with Automattic/cli-table.
npm install tty-table
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
296 Stars
447 Commits
31 Forks
7 Watchers
3 Branches
13 Contributors
Updated on Jul 16, 2025
Latest Version
4.2.3
Package Id
tty-table@4.2.3
Unpacked Size
48.54 kB
Size
15.34 kB
File Count
13
NPM Version
9.8.1
Node Version
18.16.1
Published on
Oct 29, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
29
Display your data in a table using a terminal, browser, or browser console.
See here for complete example list
To view all example output:
1$ git clone https://github.com/tecfu/tty-table && cd tty-table && npm i 2$ npm run view-examples
examples/styles-and-formatting.js
$ node examples/data/fake-stream.js | tty-table --format json --header examples/config/header.js
$ tty-table -h
View in Chrome or Chromium at http://localhost:8070/examples/browser-example.html using a dockerized apache instance:
1git clone https://github.com/tecfu/tty-table 2cd tty-table 3docker run -dit --name tty-table-in-browser -p 8070:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
array
, rows array
, options object
)Param | Type | Description |
---|---|---|
header | array | Per-column configuration. An array of objects, one object for each column. Each object contains properties you can use to configure that particular column. See available properties |
rows | array | Your data. An array of arrays or objects. See examples |
options | object | Global table configuration. See available properties |
array of objects
Param | Type | Description |
---|---|---|
alias | string | Text to display in column header cell |
align | string | default: "center" |
color | string | default: terminal default color |
footerAlign | string | default: "center" |
footerColor | string | default: terminal default color |
formatter | function(cellValue, columnIndex, rowIndex, rowData, inputData | Runs a callback on each cell value in the parent column. Please note that fat arrow functions () => {} don't support scope overrides, and this feature won't work correctly within them. |
@formatter configure | function(object) | Configure cell properties. For example: this.configure({ truncate: false, align: "left" }) More here. |
@formatter resetStyle | function(cellValue) | Removes ANSI escape sequences. For example: this.resetStyle("[32m myText[39m") // "myText" |
@formatter style | function(cellValue, effect) | Style cell value. For example: this.style("mytext", "bold", "green", "underline") For a full list of options in the terminal: chalk. For a full list of options in the browser: kleur |
headerAlign | string | default: "center" |
headerColor | string | default: terminal's default color |
marginLeft | integer | default: 0 |
marginTop | integer | default: 0 |
paddingBottom | integer | default: 0 |
paddingLeft | integer | default: 1 |
paddingRight | integer | default: 1 |
paddingTop | integer | default: 0 |
value | string | Name of the property to display in each cell when data passed as an array of objects |
width | string || integer | default: "auto" Can be a percentage of table width i.e. "20%" or a fixed number of columns i.e. "20". When set to the default ("auto"), the column widths are made proportionate by the longest value in each column. Note: Percentage columns and fixed value colums not intended to be mixed in the same table. |
Example
1let header = [{ 2 value: "item", 3 headerColor: "cyan", 4 color: "white", 5 align: "left", 6 width: 20 7}, 8{ 9 value: "price", 10 color: "red", 11 width: 10, 12 formatter: function (value) { 13 let str = `$${value.toFixed(2)}` 14 return (value > 5) ? this.style(str, "green", "bold") : 15 this.style(str, "red", "underline") 16 } 17}]
array
Example
1const rows = [ 2 ["hamburger",2.50], 3]
1const rows = [ 2 { 3 item: "hamburger", 4 price: 2.50 5 } 6]
array
Example
1const footer = [ 2 "TOTAL", 3 function (cellValue, columnIndex, rowIndex, rowData) { 4 let total = rowData.reduce((prev, curr) => { 5 return prev + curr[1] 6 }, 0) 7 .toFixed(2) 8 9 return this.style(`$${total}`, "italic") 10 } 11]
object
Param | Type | Description |
---|---|---|
borderStyle | string | default: "solid". options: "solid", "dashed", "none" |
borderColor | string | default: terminal default color |
color | string | default: terminal default color |
compact | boolean | default: false Removes horizontal borders when true. |
defaultErrorValue | mixed | default: '�' |
defaultValue | mixed | default: '?' |
errorOnNull | boolean | default: false |
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 "..." Note: tty-table wraps overflowing cell text into multiple lines by default, so you would likely only utilize truncate for extremely long values. |
width | string | default: "100%" Width of the table. Can be a percentage of i.e. "50%" or a fixed number of columns in the terminal viewport i.e. "100". Note: When you use a percentage, your table will be "responsive". |
Example
1const options = { 2 borderStyle: "solid", 3 borderColor: "blue", 4 headerAlign: "center", 5 align: "left", 6 color: "white", 7 truncate: "...", 8 width: "90%" 9}
String
Add method to render table to a string
Example
1const out = Table(header,rows,options).render() 2console.log(out); //prints output
1$ npm install tty-table -g
1$ npm install tty-table
1import Table from 'https://cdn.jsdelivr.net/gh/tecfu/tty-table/dist/tty-table.esm.js' 2let Table = require('tty-table') // https://cdn.jsdelivr.net/gh/tecfu/tty-table/dist/tty-table.cjs.js 3let Table = TTY_Table; // https://cdn.jsdelivr.net/gh/tecfu/tty-table/dist/tty-table.umd.js
Node Version | tty-table Version |
---|---|
8 | >= 2.0 |
0.11 | >= 0.0 |
1$ npm test
1$ npm run coverage
1$ npm run save-tests
1$ npm run tags
1$ npm run watch-tags
Pull requests are encouraged!
If you aren't familiar with Conventional Commits, here's a good article on the topic
TL/DR:
Copyright 2015-2020, Tecfu.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/16 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
29 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More