Pretty print in MongoDB shell as default

raffian picture raffian · Feb 5, 2012 · Viewed 138.1k times · Source

Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it's difficult to read, especially with nested arrays and documents.

Answer

Sergio Tulentsev picture Sergio Tulentsev · Feb 5, 2012

(note: this is answer to original version of the question, which did not have requirements for "default")

You can ask it to be pretty.

db.collection.find().pretty()