Mongodb – Pretty print in MongoDB shell as default

command-line-interfacemongo-shellmongodb

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.

Best Answer

(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()