MongoDB Documentation, Release 3.0.4 following: db.<collection>.find().pretty() In addition, you can use the following explicit print methods in the mongo shell: You can execute a .js file from within the mongo shell, using the load() function, as in the following: load("myjstest.js") This function loads and executes the myjstest.js file. The load() method accepts relative and absolute paths. If the current working directory of the mongo shell is /data/db , and the myjstest.js resides in the /data/db/scripts directory, then the following calls within the mongo shell would be equivalent: load("scripts/myjstest.js") load("/data/db/scripts/myjstest.js") Note: There is no search path for the load() function. If the desired script is not in the current working directory or the full specified path, mongo will not be able to access the file. You may modify the content of the prompt by creating the variable prompt in the shell. The prompt variable can hold strings as well as any arbitrary JavaScript. If prompt holds a function that returns a string, mongo can display dynamic information in each prompt. Consider the following examples: Create a prompt with the number of operations issued in the current session, define the following variables: The prompt would then resemble the following: To create a mongo shell prompt in the form of <database>@<hostname>$ define the following variables: Example Example Use a Custom Prompt Evaluate a JavaScript File • print() to print without formatting • print(tojson(<obj>)) to print with JSON formatting and equivalent to printjson() • printjson() to print with JSON formatting and equivalent to print(tojson(<obj>)) cmdCount = 1; prompt = function () { return (cmdCount++) + "> "; } 1> db.collection.find() 2> show collections 3> Chapter 5. Administration 274