Pretty print in MongoDB shell as default


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.

This question is tagged with mongodb command-line-interface mongo-shell

~ Asked on 2012-02-05 01:19:52

The Best Answer is


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

You can ask it to be pretty.


~ Answered on 2012-02-05 03:19:23


You can add

DBQuery.prototype._prettyShell = true

to your file in $HOME/.mongorc.js to enable pretty print globally by default.

~ Answered on 2012-07-09 14:47:02

Most Viewed Questions: