Categories
Node.js Quick Tips Quick Tips

Format JavaScript objects and arrays in debug output

< 1 min read

If you’re debugging in Node.js and you want a large object or array to be more readable when you log it, you can format it like this:

JSON.stringify(yourObject, null, 2)
code
output