tty-table
Health Pass
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 308 GitHub stars
Code Fail
- fs module — File system access in adapters/terminal-adapter.js
- child_process — Shell command execution capability in examples/cli-test.js
- execSync — Synchronous shell command execution in examples/cli-test.js
- process.env — Environment variable access in examples/cli-test.js
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Cross-platform terminal table (Windows, Linux, macOS). Can also run in the browser console and provide. MCP server gives your coding agent with a quick way to add text-wrapped ASCII tables to your README or other files.
tty-table
A TypeScript-first terminal table renderer with a compatibility-oriented factory API.
Examples
See here for complete example list
To view all example output:
$ git clone https://github.com/tecfu/tty-table && cd tty-table && npm i
$ npm run view-examples
Terminal (Static)
examples/styles-and-formatting.js
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
MCP server
Expose tty-table to MCP clients (Claude, IDE agents, Cursor, etc.) over stdio.
Client configuration
{
"mcpServers": {
"tty-table": {
"command": "npx",
"args": ["-y", "--package=tty-table", "tty-table-mcp"]
}
}
}
Tools
| Tool | Description |
|---|---|
render_table |
Render data as an ASCII/Unicode terminal table. Accepts header, rows, and any tty-table options; returns the rendered table as text. |
Arguments for render_table:
| Name | Type | Required | Description |
|---|---|---|---|
header |
(string | {value, align?, width?})[] |
no | Column definitions |
rows |
(unknown[] | Record<string, unknown>)[] |
yes | Row data (arrays of cells, or objects keyed by column name) |
options |
object |
no | Any tty-table option (e.g. width, borderStyle, align, compact) |
Example tool call:
{
"header": [{ "value": "name" }, { "value": "score", "align": "right" }],
"rows": [["Ada", 100], ["Grace", 98]],
"options": { "width": 40 }
}
Rendered result:
┌───────┬───────┐
│ name │ score │
├───────┼───────┤
│ Ada │ 100 │
├───────┼───────┤
│ Grace │ 98 │
└───────┴───────┘
Additional tools may be added in future releases under the same MCP server.
Browser & Browser Console
View in Chrome or Chromium at http://localhost:8070/examples/browser-example.html using a dockerized apache instance:
git clone https://github.com/tecfu/tty-table cd tty-table docker run -dit --name tty-table-in-browser -p 8070:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
What's new in 6.0
- ANSI-safe display-width calculation and Unicode-aware wrapping/truncation.
- Typed column/table options and formatter context.
- ESM and CommonJS package exports.
- Modern Node.js LTS baseline (Node 20+).
- A standalone browser bundle is produced for direct use from a browser console or
<script>tag. - Legacy
Table(header, rows, footer, options)andTable(rows, options)construction remains supported.
Compatibility
Node.js
v6 requires Node.js 20 or newer. This is a breaking change from the v5 line, which supported older Node.js releases. If your application must remain on an older Node version, stay on the v5 release line.
The published package provides both ESM and CommonJS entry points for Node.js. The CLI requires Node.js 20+ as well.
API
import Table from "tty-table"
const table = Table(
[{ value: "name" }, { value: "score", align: "right" }],
[
{ name: "Ada", score: 100 },
{ name: "Grace", score: 98 }
],
{ borderStyle: "solid" }
)
console.log(table.render())
Formatter context
New code can use the explicit context form:
const formatter = (value: unknown) => String(value).toUpperCase()
The compatibility callback signature is still accepted. New integrations should prefer a formatter that accepts the documented context object and avoid relying on dynamic this mutation.
Width semantics
Widths are measured in terminal display columns, not JavaScript string length. ANSI escape sequences are ignored for measurement; wide Unicode characters are counted using wcwidth. Wrapping and truncation operate on the same measurement primitive.
Development
npm install
npm run typecheck
npm run build
npm test
npm run test:unit
npm run lint
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found