Log a table of objects with console.table
Print an array of objects as an aligned table with console.table, choose columns with a second argument, and read the output in Node.js 24 or a browser.
Logging an array of objects as [Object, Object] hides the data. console.table prints one row per item and one column per key, so you can compare values at a glance.
const users = [
{ id: 1, name: "Ada" },
{ id: 2, name: "Linus" },
];
console.table(users);
console.table(users, ["name"]);┌─────────┬────┬─────────┐
│ (index) │ id │ name │
├─────────┼────┼─────────┤
│ 0 │ 1 │ 'Ada' │
│ 1 │ 2 │ 'Linus' │
└─────────┴────┴─────────┘
┌─────────┬─────────┐
│ (index) │ name │
├─────────┼─────────┤
│ 0 │ 'Ada' │
│ 1 │ 'Linus' │
└─────────┴─────────┘The second argument limits the columns, which helps when each object has dozens of keys. Browsers draw a real table in the console instead of box characters and let you sort by clicking a header. See console.table in the Node.js docs.
Older Node.js releases center the cell text rather than left-aligning it, so the spacing can differ. The method also gets slow with thousands of rows, so log a slice.