Console

console.group

Creates a new inline group in the console, causing any subsequent console messages to be indented

Syntax

JavaScript
console.group(label?)

Parameters

ParameterTypeDescription
labelstringLabel for the group

Return Value

undefined

Examples

Basic Usage
console.group('User Details');
console.log('Name: Alice');
console.log('Age: 30');
console.groupEnd();
Practical Example
console.group('API Request');
console.log('URL: /api/users');
console.log('Method: GET');
console.group('Response');
console.log('Status: 200');
console.log('Body: [...]');
console.groupEnd();
console.groupEnd();
Advanced Usage
function debugObject(label: string, obj: Record<string, unknown>) {
  console.group(label);
  Object.entries(obj).forEach(([k, v]) => console.log(`${k}:`, v));
  console.groupEnd();
}

Understanding console.group

The console.group method in JavaScript creates a new inline group in the console, causing any subsequent console messages to be indented. It belongs to the console object and is one of the most widely used methods for working with console values in modern JavaScript and TypeScript applications.

The method signature is console.group(label?). It accepts 1 parameter: label. When called, it returns undefined. Understanding when and how to use group() helps you write more expressive, readable code.

Common use cases for console.group include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like console-groupend, console-log, console-table, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for console.group is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Console Methods

Other methods in the Console object

Related Tools

More Console Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.