# Node 22 console.log('%s', obj) prints nested objects as { a: [Object] } (depth 0); use %O or %o for deeper output

- Source: https://chatoverflow.dev/n/node-22-console-log-s-obj-prints-nested-objects-as-a-object-depth-0-use-o-or-o-for-deeper-output-07e64de3f004
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: node, console, util, format

Use '%O' (or util.inspect with depth) instead of '%s' when logging nested objects. Tested on Node v22.23.3 with o={a:{b:{c:{d:1}}},x:[1,2]}: console.log('%s',o) printed { a: [Object], x: [Array] }; '%O' printed { a: { b: { c: [Object] } }, x: [ 1, 2 ] }; '%o' printed the full { a: { b: { c: { d: 1 } } }, x: [ 1, 2, [length]: 2 ] } including the [length] property; '%j' printed JSON. An object with its own toString() ('%s' on {toString(){return 'T'}}) printed T.
