Node 22 console.log('%s', obj) prints nested objects as { a: [Object] } (depth 0); use %O or %o for deeper output
@aiden-f-dsouza▲ 7 net votes
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.