{"id":18533574,"url":"https://github.com/oclif/table","last_synced_at":"2026-04-01T19:31:58.353Z","repository":{"id":257808730,"uuid":"861840436","full_name":"oclif/table","owner":"oclif","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-21T11:39:35.000Z","size":2035,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-21T21:40:04.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oclif.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-23T15:44:01.000Z","updated_at":"2026-03-21T11:39:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"21bf5f46-a8aa-4a92-b711-207ab8f05471","html_url":"https://github.com/oclif/table","commit_stats":null,"previous_names":["oclif/table"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/oclif/table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclif%2Ftable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclif%2Ftable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclif%2Ftable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclif%2Ftable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oclif","download_url":"https://codeload.github.com/oclif/table/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclif%2Ftable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T19:12:10.577Z","updated_at":"2026-04-01T19:31:58.345Z","avatar_url":"https://github.com/oclif.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://user-images.githubusercontent.com/449385/38243295-e0a47d58-372e-11e8-9bc0-8c02a6f4d2ac.png\" width=\"260\" height=\"73\"\u003e\n\n[![Version](https://img.shields.io/npm/v/@oclif/table.svg)](https://npmjs.org/package/@oclif/table)\n[![Downloads/week](https://img.shields.io/npm/dw/@oclif/table.svg)](https://npmjs.org/package/@oclif/table)\n[![License](https://img.shields.io/npm/l/@oclif/table.svg)](https://github.com/oclif/table/blob/main/LICENSE)\n\n### Description\n\nPrint beautiful, flexible tables to the terminal using [Ink](https://www.npmjs.com/package/ink). This library powers many oclif/Salesforce CLIs and is built for real-world, production output: wide columns, multi-line cells, smart wrapping/truncation, theming, and great CI behavior.\n\n### Features\n\n- Rich rendering via Ink with graceful fallback to plain text in CI\n- Automatic column sizing with max/explicit width support (including percentages)\n- Per-column alignment, padding, and overflow control (wrap, truncate, middle/start/end)\n- Header formatting with `change-case` presets or custom function\n- Multiple border styles (outline, headers-only, vertical/horizontal, none, and more)\n- Sort and filter data, optionally per-column\n- Print multiple tables side-by-side or stacked with layout controls\n- Return a string (`makeTable`) or print directly (`printTable`/`printTables`)\n- TypeScript-first API with excellent types\n\n---\n\n### Requirements\n\n- Node.js \u003e= 18\n- ESM only (this package has `\"type\": \"module\"`). Use `import`, not `require`.\n\n### Installation\n\n```bash\nnpm install @oclif/table\n# or\nyarn add @oclif/table\n# or\npnpm add @oclif/table\n# or\nbun add @oclif/table\n```\n\n### Quick start\n\n```js\nimport {printTable} from '@oclif/table'\n\nconst data = [\n  {name: 'Alice', role: 'Engineer', notes: 'Loves distributed systems'},\n  {name: 'Bob', role: 'Designer', notes: 'Enjoys typography and UI'},\n]\n\nprintTable({\n  title: 'Team',\n  data,\n  columns: [\n    {key: 'name', width: 16},\n    {key: 'role', width: 14, horizontalAlignment: 'center'},\n    {key: 'notes', overflow: 'wrap'},\n  ],\n})\n```\n\nTo generate a string instead of printing to stdout:\n\n```js\nimport {makeTable} from '@oclif/table'\n\nconst output = makeTable({data, columns: ['name', 'role', 'notes']})\n// do something with `output`\n```\n\nTo print multiple tables in one layout:\n\n```js\nimport {printTables} from '@oclif/table'\n\nprintTables(\n  [\n    {title: 'Developers', data, columns: ['name', 'role']},\n    {title: 'Notes', data, columns: ['notes']},\n  ],\n  {direction: 'row', columnGap: 4, margin: 1},\n)\n```\n\n---\n\n### API\n\n- `printTable(options)` — renders a single table to stdout.\n- `makeTable(options): string` — renders a single table and returns the output string.\n- `printTables(tables, options?)` — renders multiple tables with layout controls.\n\nAll three accept the same `TableOptions\u003cT\u003e` (documented below). `printTables` accepts an array of `TableOptions` plus optional container layout props.\n\n#### TypeScript\n\n```ts\nimport type {TableOptions} from '@oclif/table'\n\ntype Row = {name: string; age: number}\nconst opts: TableOptions\u003cRow\u003e = {\n  data: [{name: 'Ada', age: 36}],\n  columns: [\n    {key: 'name', name: 'Full Name'},\n    {key: 'age', horizontalAlignment: 'right'},\n  ],\n}\n```\n\n---\n\n### Options reference\n\nBelow are the most important options with defaults and behavior. See examples in `./examples` for more patterns.\n\n- `data` (required): array of rows, each a plain object.\n- `columns`: list of keys or objects describing each column.\n  - String form: `'name'` (uses key as header)\n  - Object form: `{ key, name?, width?, padding?, overflow?, horizontalAlignment?, verticalAlignment? }`\n    - `name`: header label (defaults to key or formatted with `headerOptions.formatter`)\n    - `width`: number of characters or percentage string like `'50%'`\n    - `padding`: spaces added on both sides (default: table `padding`)\n    - `overflow`: `'wrap' | 'truncate' | 'truncate-start' | 'truncate-middle' | 'truncate-end'`\n    - `horizontalAlignment`: `'left' | 'center' | 'right'`\n    - `verticalAlignment`: `'top' | 'center' | 'bottom'`\n\n- `padding` (number): cell padding for all columns. Default: `1`.\n\n- `maxWidth` (number | percentage | 'none'): maximum table width. Defaults to terminal width.\n  - When the natural table width exceeds `maxWidth`, columns shrink and content wraps/truncates based on `overflow`.\n  - Use `'none'` to allow unlimited width (useful for very wide outputs; users can resize their terminals).\n\n- `width` (number | percentage): exact table width. Overrides `maxWidth`. If wider than the natural width, columns expand evenly.\n\n- `overflow`: cell overflow behavior. Default: `'truncate'`.\n  - `'wrap'` wraps long content\n  - `'truncate'` truncates the end\n  - `'truncate-start' | 'truncate-middle' | 'truncate-end'` choose truncation position\n\n- `headerOptions`: style options for headers.\n  - `formatter`: either a function `(header: string) =\u003e string` or a `change-case` preset name:\n    `'camelCase' | 'capitalCase' | 'constantCase' | 'kebabCase' | 'pascalCase' | 'sentenceCase' | 'snakeCase'`\n  - Styling keys (also supported by `titleOptions`):\n    - `color`, `backgroundColor` (named color, hex `#rrggbb`, or `rgb(r,g,b)`)\n    - `bold`, `dimColor`, `italic`, `underline`, `strikethrough`, `inverse`\n  - Default header style is bold blue (unless `noStyle: true`).\n\n- `borderStyle`: border preset. Default: `'all'`.\n  - Available: `'all' | 'headers-only' | 'headers-only-with-outline' | 'headers-only-with-underline' | 'horizontal' | 'horizontal-with-outline' | 'none' | 'outline' | 'vertical' | 'vertical-rows-with-outline' | 'vertical-with-outline'`\n\n- `borderColor`: optional border color. When unset, the terminal's default color is used.\n\n- `horizontalAlignment`: default column alignment. Default: `'left'`.\n\n- `verticalAlignment`: default vertical alignment within cells. Default: `'top'`.\n\n- `filter(row)`: predicate to include/exclude rows.\n\n- `sort`: object mapping keys to `'asc' | 'desc' | (a,b)=\u003enumber`. Keys order defines multi-column priority.\n\n- `title`: optional string printed above the table.\n\n- `titleOptions`: style options for the title (same keys as `headerOptions` except `formatter`).\n\n- `trimWhitespace`: when wrapping text, trim whitespace at line boundaries. Default: `true`.\n\n- `noStyle`: disable all styling. Also strips ANSI color codes from your cell content for accurate width calculation.\n\n#### Container options (for `printTables`)\n\n`printTables(tables, containerOptions)` accepts:\n\n- `direction`: `'row' | 'column'` (default `'row'`)\n- `columnGap`, `rowGap`: spacing between tables\n- `alignItems`: `'flex-start' | 'center' | 'flex-end'`\n- `margin`, `marginLeft`, `marginRight`, `marginTop`, `marginBottom`\n\n---\n\n### Behavior and environment variables\n\n- Terminal width detection: by default we use your terminal width. Override with `OCLIF_TABLE_COLUMN_OVERRIDE`.\n  - Example: `OCLIF_TABLE_COLUMN_OVERRIDE=120 node app.js`\n\n- CI-safe output: in CI environments, we automatically fall back to a plain-text renderer (no Ink) for stability.\n  - To force Ink rendering in CI, set `OCLIF_TABLE_SKIP_CI_CHECK=1`.\n\n- Very large data: by default, datasets with 10,000+ rows use the plain-text renderer to avoid memory issues.\n  - Override with `OCLIF_TABLE_LIMIT=\u003cnumber\u003e` (Salesforce CLIs may also honor `SF_TABLE_LIMIT`).\n\n---\n\n### Advanced examples\n\nHeader formatting with `change-case`:\n\n```js\nimport {printTable} from '@oclif/table'\n\nprintTable({\n  data: [{first_name: 'Ada', last_name: 'Lovelace'}],\n  columns: ['first_name', 'last_name'],\n  headerOptions: {formatter: 'capitalCase'},\n})\n```\n\nPer-column sizing and overflow:\n\n```js\nprintTable({\n  data: [{name: 'A very very long name', notes: 'Multi-line\\ncontent supported'}],\n  maxWidth: '80%',\n  columns: [\n    {key: 'name', width: 20, overflow: 'truncate-middle'},\n    {key: 'notes', overflow: 'wrap', horizontalAlignment: 'right'},\n  ],\n})\n```\n\nSwitching borders and colors:\n\n```js\nprintTable({\n  title: 'Inventory',\n  titleOptions: {bold: true, color: 'cyan'},\n  data: [{item: 'Widget', qty: 10}],\n  columns: ['item', {key: 'qty', horizontalAlignment: 'right'}],\n  borderStyle: 'vertical-with-outline',\n  borderColor: 'green',\n})\n```\n\n---\n\n### Examples directory\n\nThis repo contains many runnable examples in `./examples` (including edge cases like very wide/very tall tables). Run any with:\n\n```bash\ntsx examples/basic.ts\n```\n\n---\n\n### Testing\n\nThis package includes snapshot tests for all examples to ensure consistent output across different environments.\n\n#### Running tests\n\n```bash\n# Run all tests (including snapshot tests)\nyarn test\n\n# Run only snapshot tests\nyarn test:examples\n\n# Update snapshots after intentional changes\nyarn test:examples:update\n```\n\n#### How snapshot testing works\n\nExamples are executed in an isolated child process with:\n\n- Fixed terminal width (`OCLIF_TABLE_COLUMN_OVERRIDE=120`)\n- Disabled CI detection unless an example sets it\n- ESM loader for TypeScript (`ts-node/esm`)\n\nSnapshots live in `test/__snapshots__/examples/*.txt` and mirror the `examples` directory structure.\n\n---\n\n### Contributing\n\nSee the [contributing guide](./CONRTIBUTING.md).\n\n### License\n\nMIT © Salesforce\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foclif%2Ftable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foclif%2Ftable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foclif%2Ftable/lists"}