Course contentsShow
← Web Development
Lesson 2188 of 2,98240. Browser DevTools Deep DiveFree lesson

Console.table() for Structured Data

Display arrays and objects in tabular format for easier data inspection and comparison.

Console.table() for Structured Data

You'll learn how to display arrays and objects in a clean, readable table format that makes data inspection and comparison dramatically easier.

What Is Console.table()?

While console.log() dumps data as text, console.table() transforms arrays and objects into formatted tables with rows and columns. Think of it like the difference between reading a raw CSV file versus opening it in a spreadsheet—suddenly relationships and patterns become visible.

How It Works

Pass an array or object to console.table(), and DevTools automatically creates a table where:

  • Array items or object properties become rows
  • Property names become columns
  • An automatic index column appears on the left
const users = [
  { name: 'Alice', age: 28, role: 'Developer' },
  { name: 'Bob', age: 34, role: 'Designer' },
  { name: 'Carol', age: 31, role: 'Manager' }
];

console.table(users);
// Displays a beautiful table with columns: (index) | name | age | role

When to Use It

Console.table() shines when:

  • Comparing multiple objects with the same structure (like API responses)
  • Inspecting arrays of primitives to see values and indices side-by-side
  • Debugging data transformations where you need to spot differences quickly
  • Reviewing nested data (though only one level deep displays well)

Optional Column Filtering

You can specify which columns to display as a second argument:

console.table(users, ['name', 'role']);
// Shows only name and role columns

Key Takeaway: Use console.table() whenever you're working with structured data like arrays of objects—it transforms cryptic output into scannable, sortable tables that make patterns and anomalies instantly obvious.