Course contentsShow
← Web Development
Lesson 2245 of 2,98241. Debugging TechniquesFree lesson

console.table for Structured Data

Display arrays and objects as readable tables for easier data inspection during development.

console.table for Structured Data

You'll learn how to display arrays and objects as formatted tables in the console for instant clarity when inspecting complex data structures.

Why Console.table Matters

When you're debugging arrays of objects or nested data structures, console.log() outputs can become a wall of text that's hard to parse. Imagine trying to compare properties across multiple user records or API responses by reading raw object notation—it's tedious and error-prone.

console.table() transforms this chaos into a spreadsheet-like table, making patterns, missing values, and differences jump out immediately.

How It Works

Pass an array or object to console.table(), and the browser automatically organizes it into rows and columns:

const users = [
  { id: 1, name: 'Alice', role: 'admin' },
  { id: 2, name: 'Bob', role: 'user' },
  { id: 3, name: 'Charlie', role: 'moderator' }
];

console.table(users);

This outputs a table with columns for id, name, and role—instantly readable.

You can also limit which columns appear by passing a second argument with an array of property names:

console.table(users, ['name', 'role']);

This shows only the name and role columns, focusing your inspection.

When to Use It

Use console.table() whenever you're working with:

  • Arrays of objects (API responses, database results)
  • Multiple similar items you need to compare
  • Structured data where relationships between properties matter

Think of it as your data's "spreadsheet view"—perfect for spotting outliers, null values, or inconsistencies at a glance.

Key Takeaway: console.table() converts arrays and objects into readable tables, making structured data inspection dramatically faster and clearer during development.