This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The console.dir() static method displays a list of the properties of the specified JavaScript object. In browser consoles, the output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.
Unlike other logging methods, console.dir() does not attempt to pretty-print the object. For example, if you pass a DOM element to console.dir(), it will not be displayed like in the element inspector, but will instead show a list of properties.
In runtimes like Node and Deno, where console output goes to the terminal and is therefore not interactive, the options parameter provides a way to customize the way the object is presented.
console.dir(object) console.dir(object, options)
objectA JavaScript object whose properties should be printed.
options OptionalAn object with the following properties, all optional:
colors Non-standard OptionalA boolean value: if true, style the properties of the object according to their type. Defaults to true.
depth Non-standard OptionalA number representing the number of nesting levels to print when an object contains other objects or arrays. The value null means: print all levels. Defaults to 2.
A boolean value: if true, print the object's non-enumerable and symbol properties. Defaults to false.
None (undefined).
| Specification |
|---|
| Console> # dir> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
dir_static |
2 | 12 | 8 | 11 | 4 | 18 | 8 | 11 | 3.2 | 1.0 | 4.4 | 3.2 |
options_colors_parameter |
No | No | No | No | No | No | No | No | No | No | No | No |
options_depth_parameter |
No | No | No | No | No | No | No | No | No | No | No | No |
options_showHidden_parameter |
No | No | No | No | No | No | No | No | No | No | No | No |
console.dir()console.dir()console.dir()
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/console/dir_static