Styleable plain-text table generator. Useful for formatting console output.
Installations
npm install table-layout
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
>=12.17
Node Version
22.5.1
NPM Version
10.8.2
Score
99.4
Supply Chain
99.6
Quality
78.5
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
JavaScript (97.18%)
HTML (2.82%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
75lb
Download Statistics
Total Downloads
286,340,672
Last Day
410,116
Last Week
2,271,055
Last Month
9,228,038
Last Year
86,805,007
GitHub Statistics
MIT License
23 Stars
227 Commits
6 Forks
2 Watchers
3 Branches
5 Contributors
Updated on Nov 09, 2024
Bundle Size
6.70 kB
Minified
2.22 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.1.1
Package Id
table-layout@4.1.1
Unpacked Size
60.54 kB
Size
13.13 kB
File Count
13
NPM Version
10.8.2
Node Version
22.5.1
Published on
Jul 31, 2024
Total Downloads
Cumulative downloads
Total Downloads
286,340,672
Last Day
5.3%
410,116
Compared to previous day
Last Week
2.1%
2,271,055
Compared to previous week
Last Month
8.1%
9,228,038
Compared to previous month
Last Year
34.7%
86,805,007
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
table-layout
Styleable plain-text table generator. Useful for formatting console output. Available as both a command-line tool and isomorphic Javascript library.
Install as a library
Add table-layout to your project:
$ npm install --save table-layout
Display an array of objects as a table
Trivial example. Read a JSON file from disk and output a table with a maximum width (in characters) of 60.
1import Table from 'table-layout' 2import { promises as fs } from 'fs' 3 4const issues = await fs.readFile('./issues.json', 'utf8') 5const table = new Table(JSON.parse(issues), { maxWidth: 60 }) 6 7console.log(table.toString()) 8
This is the example input file:
1[ 2 { 3 "number": 15134, 4 "title": "Coveralls has no source available ", 5 "login": "ndelangen", 6 "comments": 0 7 }, 8 { 9 "number": 15133, 10 "title": "Fixing --preserve-symlinks. Enhancing node to exploit.", 11 "login": "phestermcs", 12 "comments": 0 13 }, 14 { 15 "number": 15131, 16 "title": "Question - Confused about NPM's local installation philosophy", 17 "login": "the1mills", 18 "comments": 0 19 }, 20 { 21 "number": 15130, 22 "title": "Question - global npm cache directory if user is root?", 23 "login": "ORESoftware", 24 "comments": 0 25 } 26]
This is the output:
15134 Coveralls has no source available ndelangen 0
15133 Fixing --preserve-symlinks. phestermcs 0
Enhancing node to exploit.
15131 Question - Confused about NPM's the1mills 0
local installation philosophy
15130 Question - global npm cache ORESoftware 0
directory if user is root?
15127 how to installa gulp fontfacegen aramgreat 0
on Windows 10
15097 Cannot install package from mastertinner 3
tarball out of package.json entry
generated by npm
15067 npm "SELF_SIGNED_CERT_IN_CHAIN" LegendsLyfe 3
error when installing discord.js
with .log
Cherry-picked and computed values
Sometimes, your input data might contain a deeper structure or you want to transform or compute some values. Some example input data with structural depth and large numbers you'd like to reformat:
1[ 2 { 3 "country": { "name": "USA" }, 4 "GDP": 19485394000000, 5 "population": 325084756 6 }, 7 { 8 "country": { "name": "China" }, 9 "GDP": 12237700479375, 10 "population": 1421021791 11 }, 12 { 13 "country": { "name": "Japan" }, 14 "GDP": 4872415104315, 15 "population": 127502725 16 } 17]
Example usage of the column getter function:
1import Table from 'table-layout' 2import { promises as fs } from 'fs' 3 4const rows = JSON.parse(await fs.readFile('./example/deep-data/gdp.json', 'utf8')) 5const germanCurrency = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }) 6const germanNumber = new Intl.NumberFormat('de-DE', { notation: 'compact', maximumSignificantDigits: 3, maximumFractionDigits: 0 }) 7 8const table = new Table(rows, { 9 maxWidth: 60, 10 columns: [ 11 { 12 name: 'country', 13 get: (cellValue) => cellValue.name 14 }, 15 { 16 name: 'GDP', 17 get: (cellValue) => germanCurrency.format(cellValue) 18 }, 19 { 20 name: 'population', 21 get: (cellValue) => germanNumber.format(cellValue) 22 }, 23 ] 24}) 25 26console.log(table.toString())
Output.
$ node example/computed-values.js
USA 19.485.394.000.000,00 € 325 Mio.
China 12.237.700.479.375,00 € 1,42 Mrd.
Japan 4.872.415.104.315,00 € 128 Mio.
Colour-scale conditional formatting
See this file for a example of colour-scale formatting (increasing intensity of red/green for more positive/negative values).

API Reference
For the full API documentation, see here.
Load anywhere
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Within a Node.js CommonJS Module:
1const Table = require('table-layout')
Within a Node.js ECMAScript Module:
1import Table from 'table-layout'
Within a modern browser ECMAScript Module:
1import Table from './node_modules/table-layout/dist/index.mjs'
See Also
- gfmt: A github-flavoured-markdown table generator.
© 2015-24 Lloyd Brookes <75pound@gmail.com>.
Isomorphic test suite by test-runner. Documented by jsdoc-to-markdown.

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/75lb/table-layout/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/75lb/table-layout/node.js.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/node.js.yml:29
- Warn: npmCommand not pinned by hash: .github/workflows/node.js.yml:30
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Score
3.4
/10
Last Scanned on 2025-03-17
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 MoreOther packages similar to table-layout
cliui
easily create complex multi-column command-line-interfaces
@isaacs/cliui
easily create complex multi-column command-line-interfaces
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.
@riil-frontend/component-table-layout
上面是过滤,中间,下面分页器的布局