ag-grid, datatables.net, gridjs, handsontable, react-data-grid, and react-table are JavaScript libraries for displaying and interacting with tabular data in web applications. They provide features like sorting, filtering, pagination, and editing, but differ significantly in architecture, framework integration, performance characteristics, and licensing. The table package is a Node.js utility for formatting data in terminal output and is not intended for browser-based UIs.
When building data-intensive web applications — dashboards, admin panels, financial tools, or CRMs — choosing the right grid library is a foundational architectural decision. The packages ag-grid, datatables.net, gridjs, handsontable, react-data-grid, react-table, and table each offer different trade-offs in rendering strategy, framework integration, feature depth, and developer ergonomics. Let’s examine them through real-world engineering lenses.
ag-grid, react-data-grid, and gridjs use virtualized rendering: they only render rows currently visible in the viewport, enabling smooth performance with tens of thousands of records.
// ag-grid (React)
import { AgGridReact } from 'ag-grid-react';
<AgGridReact
rowData={largeDataSet}
columnDefs={columns}
domLayout="autoHeight"
/>
// react-data-grid
import DataGrid from 'react-data-grid';
<DataGrid
columns={columns}
rows={rows}
rowHeight={35}
/>
// gridjs (vanilla JS)
new gridjs.Grid({
columns: ['Name', 'Email'],
data: fetchData(),
pagination: true
}).render(document.getElementById("wrapper"));
In contrast, datatables.net and handsontable manipulate the full HTML <table> DOM, which can cause performance issues beyond ~1,000 rows unless server-side processing is used.
// datatables.net
$('#myTable').DataTable({
data: localData,
columns: [
{ title: 'Name' },
{ title: 'Position' }
]
});
// handsontable
const hot = new Handsontable(container, {
data: spreadsheetData,
colHeaders: true,
rowHeaders: true,
contextMenu: true
});
react-table is not a UI component at all — it’s a headless hook that provides state and logic; you render the table yourself using standard HTML or custom components.
// react-table
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow
} = useReactTable({ columns, data });
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(row => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => <td {...cell.getCellProps()}>{cell.render('Cell')}</td>)}
</tr>
);
})}
</tbody>
</table>
table is a Node.js utility for formatting tabular data in terminals — not a browser-based UI library. It should not be considered for frontend grid implementations.
⚠️ Important: The
tablenpm package is deprecated for browser use. Its documentation states it is intended for CLI output. Do not use it to build interactive web tables.
react-table and react-data-grid are built exclusively for React, leveraging hooks and functional components. They integrate cleanly into modern React architectures.
ag-grid offers official wrappers for React, Angular, and Vue, but its core is framework-agnostic. This gives flexibility but adds abstraction layers.
gridjs is framework-agnostic by design and works in vanilla JS, React, Vue, etc., via simple initialization.
datatables.net originated as a jQuery plugin. While it now supports non-jQuery usage, much of its ecosystem (plugins, extensions) still assumes jQuery. This can complicate integration in modern SPAs.
handsontable provides React, Angular, and Vue wrappers, but its core API is imperative and object-oriented, which can feel out of place in declarative frameworks.
If your app requires Excel-like editing, handsontable is purpose-built for this:
new Handsontable(container, {
data: initialData,
columns: [
{ type: 'text' },
{ type: 'numeric', numericFormat: { pattern: '0,0.00' } },
{ type: 'date', dateFormat: 'MM/DD/YYYY' }
],
contextMenu: true,
undo: true
});
ag-grid also supports rich cell editors (dropdowns, sliders, custom React components):
const columnDefs = [
{
field: 'country',
cellEditor: 'agSelectCellEditor',
cellEditorParams: { values: ['US', 'UK', 'CA'] }
}
];
react-data-grid allows custom editor components per column:
const columns = [
{
key: 'status',
name: 'Status',
editor: <DropDownEditor options={['Active', 'Inactive']} />
}
];
gridjs supports basic inline editing but lacks advanced cell types:
new gridjs.Grid({
columns: [{ name: 'Name', editable: true }],
data: [...]
});
datatables.net requires the separate Editor extension (commercial license) for robust editing. The free version has minimal editing support.
react-table leaves editing entirely to you — you must build input controls and state management yourself.
| Feature | ag-grid | datatables.net | gridjs | handsontable | react-data-grid | react-table | table |
|---|---|---|---|---|---|---|---|
| Sorting | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (logic) | ❌ |
| Filtering | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (logic) | ❌ |
| Pagination | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (logic) | ❌ |
| Row Grouping | ✅ | ✅ (plugin) | ❌ | ✅ | ✅ | ✅ (plugin) | ❌ |
| Tree Data | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ (plugin) | ❌ |
| Excel Export | ✅ (core) | ✅ (plugin) | ✅ | ✅ | ❌ | ❌ | ❌ |
| Custom Cell Renderers | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Server-Side Operations | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
Note: react-table provides hooks for these features but no UI; you implement visuals.
ag-grid: Ships with multiple built-in themes (Balham, Alpine, Material). Customization requires overriding CSS variables or classes.datatables.net: Uses legacy CSS; theming often involves deep overrides.gridjs: Modern CSS with easy theme customization via config.handsontable: Full theming system with skin support.react-data-grid: Minimal default styles; designed to be styled with CSS-in-JS or Tailwind.react-table: No styles — complete control.ag-grid: Free "Community" version lacks advanced features (row grouping, Excel export, server-side row model). Enterprise features require paid license.handsontable: Free for non-commercial use; commercial projects need a license.datatables.net: Core is MIT, but powerful extensions (Editor, SearchBuilder) are proprietary.gridjs, react-data-grid, react-table: Fully MIT licensed — free for any use.table: MIT, but irrelevant for browser UI.ag-gridYou need enterprise-grade features (grouping, pivoting, Excel export) and are willing to navigate licensing tiers. Ideal for financial or analytics dashboards where performance and functionality outweigh bundle size concerns.
datatables.netYou’re maintaining a legacy jQuery application or need quick integration with minimal setup. Avoid in new React/Vue/Angular SPAs unless you’re committed to managing jQuery alongside modern frameworks.
gridjsYou want a lightweight, modern, framework-agnostic grid with good defaults and MIT licensing. Great for internal tools or MVPs where you don’t need spreadsheet-level editing.
handsontableYour users expect an Excel-like experience: formulas, drag-to-fill, context menus, and complex cell types. Accept the licensing cost if your project is commercial.
react-data-gridYou’re in a React-only environment and need a balance of performance (virtualization), customization, and open-source freedom. Best when you want control without the complexity of headless libraries.
react-tableYou need maximum design flexibility and already have a strong UI system (e.g., using Tailwind or a custom component library). You’re comfortable building table UI from scratch but want battle-tested logic for sorting, filtering, and pagination.
tableNever use table for browser-based interactive grids. It’s a terminal formatting tool — including it in a frontend bundle adds unnecessary weight and provides zero interactivity.
There’s no universal “best” grid library — only the right tool for your constraints:
handsontablereact-table or react-data-gridgridjsag-griddatatables.netAvoid table entirely for web UIs. Evaluate based on your team’s framework expertise, design system maturity, data scale, and licensing tolerance.
Do not choose table for browser-based interactive grids. It is a Node.js package designed exclusively for formatting tabular data in terminal/console output and provides no DOM rendering or user interaction capabilities. Using it in frontend code adds unnecessary bundle weight and offers no practical benefit.
Choose react-table when you need maximum UI flexibility and already have a strong design system or component library. As a headless utility, it provides robust data logic (sorting, filtering, pagination) while leaving all rendering to you, which is perfect for branded or highly customized table implementations.
Choose datatables.net primarily for legacy jQuery projects or simple server-rendered pages where quick setup is valued over modern framework integration. Avoid it in new React, Vue, or Angular SPAs due to its jQuery roots and limited compatibility with component-based architectures.
Choose react-data-grid for React-only applications that need virtualized rendering for large datasets, customizable components, and full MIT licensing. It strikes a balance between functionality and simplicity, making it suitable for dashboards and data-heavy interfaces without the overhead of larger libraries.
Choose handsontable when your application requires an Excel-like user experience with features such as formula support, drag-to-fill, context menus, and rich cell editors. Be aware that commercial projects require a paid license, but the spreadsheet fidelity may justify the cost.
Choose gridjs when you need a lightweight, modern, framework-agnostic grid with MIT licensing and decent built-in features like sorting, pagination, and basic editing. It's ideal for internal tools or prototypes where you want minimal configuration and no licensing concerns.
Choose ag-grid when you need a full-featured, high-performance grid with enterprise capabilities like row grouping, pivoting, and Excel export, and you're prepared to handle its dual licensing model (free Community vs paid Enterprise). It's well-suited for complex data analysis applications where out-of-the-box functionality reduces development time.
Produces a string that represents array data in a text table.

npm install table
import { table } from 'table';
// Using commonjs?
// const { table } = require('table');
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
console.log(table(data));
╔════╤════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════╧════╝
Returns the string in the table format
Parameters:
data: The data to display
any[][]trueconfig: Table configuration
objectfalseType: { [type: string]: string }
Default: honeywell template
Custom borders. The keys are any of:
topLeft, topRight, topBody,topJoinbottomLeft, bottomRight, bottomBody, bottomJoinjoinLeft, joinRight, joinBody, joinJoinbodyLeft, bodyRight, bodyJoinheaderJoinconst data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
const config = {
border: {
topBody: `─`,
topJoin: `┬`,
topLeft: `┌`,
topRight: `┐`,
bottomBody: `─`,
bottomJoin: `┴`,
bottomLeft: `└`,
bottomRight: `┘`,
bodyLeft: `│`,
bodyRight: `│`,
bodyJoin: `│`,
joinBody: `─`,
joinLeft: `├`,
joinRight: `┤`,
joinJoin: `┼`
}
};
console.log(table(data, config));
┌────┬────┬────┐
│ 0A │ 0B │ 0C │
├────┼────┼────┤
│ 1A │ 1B │ 1C │
├────┼────┼────┤
│ 2A │ 2B │ 2C │
└────┴────┴────┘
Type: (lineIndex: number, columnCount: number) => boolean
Default: () => true
It is used to tell whether to draw a vertical line. This callback is called for each vertical border of the table.
If the table has n columns, then the index parameter is alternatively received all numbers in range [0, n] inclusively.
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C'],
['3A', '3B', '3C'],
['4A', '4B', '4C']
];
const config = {
drawVerticalLine: (lineIndex, columnCount) => {
return lineIndex === 0 || lineIndex === columnCount;
}
};
console.log(table(data, config));
╔════════════╗
║ 0A 0B 0C ║
╟────────────╢
║ 1A 1B 1C ║
╟────────────╢
║ 2A 2B 2C ║
╟────────────╢
║ 3A 3B 3C ║
╟────────────╢
║ 4A 4B 4C ║
╚════════════╝
Type: (lineIndex: number, rowCount: number) => boolean
Default: () => true
It is used to tell whether to draw a horizontal line. This callback is called for each horizontal border of the table.
If the table has n rows, then the index parameter is alternatively received all numbers in range [0, n] inclusively.
If the table has n rows and contains the header, then the range will be [0, n+1] inclusively.
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C'],
['3A', '3B', '3C'],
['4A', '4B', '4C']
];
const config = {
drawHorizontalLine: (lineIndex, rowCount) => {
return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount - 1 || lineIndex === rowCount;
}
};
console.log(table(data, config));
╔════╤════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
║ 2A │ 2B │ 2C ║
║ 3A │ 3B │ 3C ║
╟────┼────┼────╢
║ 4A │ 4B │ 4C ║
╚════╧════╧════╝
Type: boolean
Default: false
If true, horizontal lines inside the table are not drawn. This option also overrides the config.drawHorizontalLine if specified.
const data = [
['-rw-r--r--', '1', 'pandorym', 'staff', '1529', 'May 23 11:25', 'LICENSE'],
['-rw-r--r--', '1', 'pandorym', 'staff', '16327', 'May 23 11:58', 'README.md'],
['drwxr-xr-x', '76', 'pandorym', 'staff', '2432', 'May 23 12:02', 'dist'],
['drwxr-xr-x', '634', 'pandorym', 'staff', '20288', 'May 23 11:54', 'node_modules'],
['-rw-r--r--', '1,', 'pandorym', 'staff', '525688', 'May 23 11:52', 'package-lock.json'],
['-rw-r--r--@', '1', 'pandorym', 'staff', '2440', 'May 23 11:25', 'package.json'],
['drwxr-xr-x', '27', 'pandorym', 'staff', '864', 'May 23 11:25', 'src'],
['drwxr-xr-x', '20', 'pandorym', 'staff', '640', 'May 23 11:25', 'test'],
];
const config = {
singleLine: true
};
console.log(table(data, config));
╔═════════════╤═════╤══════════╤═══════╤════════╤══════════════╤═══════════════════╗
║ -rw-r--r-- │ 1 │ pandorym │ staff │ 1529 │ May 23 11:25 │ LICENSE ║
║ -rw-r--r-- │ 1 │ pandorym │ staff │ 16327 │ May 23 11:58 │ README.md ║
║ drwxr-xr-x │ 76 │ pandorym │ staff │ 2432 │ May 23 12:02 │ dist ║
║ drwxr-xr-x │ 634 │ pandorym │ staff │ 20288 │ May 23 11:54 │ node_modules ║
║ -rw-r--r-- │ 1, │ pandorym │ staff │ 525688 │ May 23 11:52 │ package-lock.json ║
║ -rw-r--r--@ │ 1 │ pandorym │ staff │ 2440 │ May 23 11:25 │ package.json ║
║ drwxr-xr-x │ 27 │ pandorym │ staff │ 864 │ May 23 11:25 │ src ║
║ drwxr-xr-x │ 20 │ pandorym │ staff │ 640 │ May 23 11:25 │ test ║
╚═════════════╧═════╧══════════╧═══════╧════════╧══════════════╧═══════════════════╝
Type: Column[] | { [columnIndex: number]: Column }
Column specific configurations.
Type: number
Default: the maximum cell widths of the column
Column width (excluding the paddings).
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
const config = {
columns: {
1: { width: 10 }
}
};
console.log(table(data, config));
╔════╤════════════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────────────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────────────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════════════╧════╝
Type: 'center' | 'justify' | 'left' | 'right'
Default: 'left'
Cell content horizontal alignment
const data = [
['0A', '0B', '0C', '0D 0E 0F'],
['1A', '1B', '1C', '1D 1E 1F'],
['2A', '2B', '2C', '2D 2E 2F'],
];
const config = {
columnDefault: {
width: 10,
},
columns: [
{ alignment: 'left' },
{ alignment: 'center' },
{ alignment: 'right' },
{ alignment: 'justify' }
],
};
console.log(table(data, config));
╔════════════╤════════════╤════════════╤════════════╗
║ 0A │ 0B │ 0C │ 0D 0E 0F ║
╟────────────┼────────────┼────────────┼────────────╢
║ 1A │ 1B │ 1C │ 1D 1E 1F ║
╟────────────┼────────────┼────────────┼────────────╢
║ 2A │ 2B │ 2C │ 2D 2E 2F ║
╚════════════╧════════════╧════════════╧════════════╝
Type: 'top' | 'middle' | 'bottom'
Default: 'top'
Cell content vertical alignment
const data = [
['A', 'B', 'C', 'DEF'],
];
const config = {
columnDefault: {
width: 1,
},
columns: [
{ verticalAlignment: 'top' },
{ verticalAlignment: 'middle' },
{ verticalAlignment: 'bottom' },
],
};
console.log(table(data, config));
╔═══╤═══╤═══╤═══╗
║ A │ │ │ D ║
║ │ B │ │ E ║
║ │ │ C │ F ║
╚═══╧═══╧═══╧═══╝
Type: number
Default: 1
The number of whitespaces used to pad the content on the left.
Type: number
Default: 1
The number of whitespaces used to pad the content on the right.
The paddingLeft and paddingRight options do not count on the column width. So the column has width = 5, paddingLeft = 2 and paddingRight = 2 will have the total width is 9.
const data = [
['0A', 'AABBCC', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
const config = {
columns: [
{
paddingLeft: 3
},
{
width: 2,
paddingRight: 3
}
]
};
console.log(table(data, config));
╔══════╤══════╤════╗
║ 0A │ AA │ 0C ║
║ │ BB │ ║
║ │ CC │ ║
╟──────┼──────┼────╢
║ 1A │ 1B │ 1C ║
╟──────┼──────┼────╢
║ 2A │ 2B │ 2C ║
╚══════╧══════╧════╝
Type: number
Default: Infinity
The number of characters is which the content will be truncated.
To handle a content that overflows the container width, table package implements text wrapping. However, sometimes you may want to truncate content that is too long to be displayed in the table.
const data = [
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
];
const config = {
columns: [
{
width: 20,
truncate: 100
}
]
};
console.log(table(data, config));
╔══════════════════════╗
║ Lorem ipsum dolor si ║
║ t amet, consectetur ║
║ adipiscing elit. Pha ║
║ sellus pulvinar nibh ║
║ sed mauris convall… ║
╚══════════════════════╝
Type: boolean
Default: false
The table package implements auto text wrapping, i.e., text that has the width greater than the container width will be separated into multiple lines at the nearest space or one of the special characters: \|/_.,;-.
When wrapWord is false:
const data = [
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
];
const config = {
columns: [ { width: 20 } ]
};
console.log(table(data, config));
╔══════════════════════╗
║ Lorem ipsum dolor si ║
║ t amet, consectetur ║
║ adipiscing elit. Pha ║
║ sellus pulvinar nibh ║
║ sed mauris convallis ║
║ dapibus. Nunc venena ║
║ tis tempus nulla sit ║
║ amet viverra. ║
╚══════════════════════╝
When wrapWord is true:
╔══════════════════════╗
║ Lorem ipsum dolor ║
║ sit amet, ║
║ consectetur ║
║ adipiscing elit. ║
║ Phasellus pulvinar ║
║ nibh sed mauris ║
║ convallis dapibus. ║
║ Nunc venenatis ║
║ tempus nulla sit ║
║ amet viverra. ║
╚══════════════════════╝
Type: Column
Default: {}
The default configuration for all columns. Column-specific settings will overwrite the default values.
Type: object
Header configuration.
Deprecated in favor of the new spanning cells API.
The header configuration inherits the most of the column's, except:
content {string}: the header content.width: calculate based on the content width automatically.alignment: center be default.verticalAlignment: is not supported.config.border.topJoin will be config.border.topBody for prettier.const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C'],
];
const config = {
columnDefault: {
width: 10,
},
header: {
alignment: 'center',
content: 'THE HEADER\nThis is the table about something',
},
}
console.log(table(data, config));
╔══════════════════════════════════════╗
║ THE HEADER ║
║ This is the table about something ║
╟────────────┬────────────┬────────────╢
║ 0A │ 0B │ 0C ║
╟────────────┼────────────┼────────────╢
║ 1A │ 1B │ 1C ║
╟────────────┼────────────┼────────────╢
║ 2A │ 2B │ 2C ║
╚════════════╧════════════╧════════════╝
Type: SpanningCellConfig[]
Spanning cells configuration.
The configuration should be straightforward: just specify an array of minimal cell configurations including the position of top-left cell and the number of columns and/or rows will be expanded from it.
The content of overlap cells will be ignored to make the data shape be consistent.
By default, the configuration of column that the top-left cell belongs to will be applied to the whole spanning cell, except:
width will be summed up of all spanning columns.paddingRight will be received from the right-most column intentionally.Advances customized column-like styles can be configurable to each spanning cell to overwrite the default behavior.
const data = [
['Test Coverage Report', '', '', '', '', ''],
['Module', 'Component', 'Test Cases', 'Failures', 'Durations', 'Success Rate'],
['Services', 'User', '50', '30', '3m 7s', '60.0%'],
['', 'Payment', '100', '80', '7m 15s', '80.0%'],
['Subtotal', '', '150', '110', '10m 22s', '73.3%'],
['Controllers', 'User', '24', '18', '1m 30s', '75.0%'],
['', 'Payment', '30', '24', '50s', '80.0%'],
['Subtotal', '', '54', '42', '2m 20s', '77.8%'],
['Total', '', '204', '152', '12m 42s', '74.5%'],
];
const config = {
columns: [
{ alignment: 'center', width: 12 },
{ alignment: 'center', width: 10 },
{ alignment: 'right' },
{ alignment: 'right' },
{ alignment: 'right' },
{ alignment: 'right' }
],
spanningCells: [
{ col: 0, row: 0, colSpan: 6 },
{ col: 0, row: 2, rowSpan: 2, verticalAlignment: 'middle'},
{ col: 0, row: 4, colSpan: 2, alignment: 'right'},
{ col: 0, row: 5, rowSpan: 2, verticalAlignment: 'middle'},
{ col: 0, row: 7, colSpan: 2, alignment: 'right' },
{ col: 0, row: 8, colSpan: 2, alignment: 'right' }
],
};
console.log(table(data, config));
╔══════════════════════════════════════════════════════════════════════════════╗
║ Test Coverage Report ║
╟──────────────┬────────────┬────────────┬──────────┬───────────┬──────────────╢
║ Module │ Component │ Test Cases │ Failures │ Durations │ Success Rate ║
╟──────────────┼────────────┼────────────┼──────────┼───────────┼──────────────╢
║ │ User │ 50 │ 30 │ 3m 7s │ 60.0% ║
║ Services ├────────────┼────────────┼──────────┼───────────┼──────────────╢
║ │ Payment │ 100 │ 80 │ 7m 15s │ 80.0% ║
╟──────────────┴────────────┼────────────┼──────────┼───────────┼──────────────╢
║ Subtotal │ 150 │ 110 │ 10m 22s │ 73.3% ║
╟──────────────┬────────────┼────────────┼──────────┼───────────┼──────────────╢
║ │ User │ 24 │ 18 │ 1m 30s │ 75.0% ║
║ Controllers ├────────────┼────────────┼──────────┼───────────┼──────────────╢
║ │ Payment │ 30 │ 24 │ 50s │ 80.0% ║
╟──────────────┴────────────┼────────────┼──────────┼───────────┼──────────────╢
║ Subtotal │ 54 │ 42 │ 2m 20s │ 77.8% ║
╟───────────────────────────┼────────────┼──────────┼───────────┼──────────────╢
║ Total │ 204 │ 152 │ 12m 42s │ 74.5% ║
╚═══════════════════════════╧════════════╧══════════╧═══════════╧══════════════╝
table package exports createStream function used to draw a table and append rows.
Parameter:
table's, except config.columnDefault.width and config.columnCount must be provided.import { createStream } from 'table';
const config = {
columnDefault: {
width: 50
},
columnCount: 1
};
const stream = createStream(config);
setInterval(() => {
stream.write([new Date()]);
}, 500);

table package uses ANSI escape codes to overwrite the output of the last line when a new row is printed.
The underlying implementation is explained in this Stack Overflow answer.
The cursor stays at the end of the table after each row, so that the next row can replace the bottom border. Call stream.end() after the last row to move the cursor below the table, so that whatever is printed next does not overwrite it. A stream cannot be written to after it has ended.
const stream = createStream(config);
for (const row of rows) {
stream.write(row);
}
stream.end();
Streaming supports all of the configuration properties and functionality of a static table (such as auto text wrapping, alignment and padding), e.g.
import { createStream } from 'table';
import _ from 'lodash';
const config = {
columnDefault: {
width: 50
},
columnCount: 3,
columns: [
{
width: 10,
alignment: 'right'
},
{ alignment: 'center' },
{ width: 10 }
]
};
const stream = createStream(config);
let i = 0;
setInterval(() => {
let random;
random = _.sample('abcdefghijklmnopqrstuvwxyz', _.random(1, 30)).join('');
stream.write([i++, new Date(), random]);
}, 500);

Parameter:
'honeywell' | 'norc' | 'ramac' | 'void'trueYou can load one of the predefined border templates using getBorderCharacters function.
import { table, getBorderCharacters } from 'table';
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
const config = {
border: getBorderCharacters(`name of the template`)
};
console.log(table(data, config));
# honeywell
╔════╤════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════╧════╝
# norc
┌────┬────┬────┐
│ 0A │ 0B │ 0C │
├────┼────┼────┤
│ 1A │ 1B │ 1C │
├────┼────┼────┤
│ 2A │ 2B │ 2C │
└────┴────┴────┘
# ramac (ASCII; for use in terminals that do not support Unicode characters)
+----+----+----+
| 0A | 0B | 0C |
|----|----|----|
| 1A | 1B | 1C |
|----|----|----|
| 2A | 2B | 2C |
+----+----+----+
# void (no borders; see "borderless table" section of the documentation)
0A 0B 0C
1A 1B 1C
2A 2B 2C
Raise an issue if you'd like to contribute a new border template.
Simply using void border character template creates a table with a lot of unnecessary spacing.
To create a more pleasant to the eye table, reset the padding and remove the joining rows, e.g.
const output = table(data, {
border: getBorderCharacters('void'),
columnDefault: {
paddingLeft: 0,
paddingRight: 1
},
drawHorizontalLine: () => false
}
);
console.log(output);
0A 0B 0C
1A 1B 1C
2A 2B 2C