Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

console.groupEnd() — end a console group

If a console group is open, console.groupEnd() ends the most recently opened group. If no group is open, the call does nothing.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

console.groupEnd();

If the console's group stack is not empty, console.groupEnd() removes the most recently opened group, created by console.group() or console.groupCollapsed(), from the stack. Subsequent messages appear one level higher, outside the group that ended. If the stack is empty, the call does nothing.

The method takes no parameters and returns undefined. It neither selects a group by label nor deletes earlier messages.

This is a Console Standard API, not an ECMAScript-defined feature. Group presentation is implementation-defined; the standard supplies no browser-version compatibility table.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>console.groupEnd example</title>
</head>
<body>
  <main><pre id="result"></pre></main>
  <script>
    const result = document.getElementById('result');
    if (typeof console.groupEnd !== 'function') {
      result.textContent = 'console.groupEnd is unavailable.';
    } else {
      const outer = 'Outer';
      const inner = 'Inner';
      const [a, b, c, d] = ['A', 'B', 'C', 'D'];

      console.group(outer);
      console.log(a);
      console.groupCollapsed(inner);
      console.log(b);
      console.groupEnd();
      console.log(c);
      console.groupEnd();
      console.log(d);

      result.textContent = [
        `In the console, expand ${inner} if it is collapsed to see ${b}.`,
        `After ending ${inner}, ${c} is back in ${outer}, alongside ${a}.`,
        `After ending ${outer}, ${d} is outside both groups.`
      ].join('\n');
    }
  </script>
</body>
</html>

Result

In the console, expand Inner if it is collapsed to see B.
After ending Inner, C is back in Outer, alongside A.
After ending Outer, D is outside both groups.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources