MongoDB Shell and Connection Basics/Pretty-print query results

Format documents for easier reading.

Section: Collection bootstrap

Pretty-print query results

javascript
javascript
db.users.find({ active: true }).pretty()
Explanation

Useful for ad hoc inspection in interactive sessions.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Collection bootstrap
Read a few documents
Preview documents from a collection.
OpenIn sheetjavascriptsame section
Create a collection
Create a collection explicitly.
OpenIn sheetjavascriptsame section
Insert one sample document
Create a starter document.
OpenIn sheetjavascriptsame section
Drop a collection
Remove a collection and its data.
OpenIn sheetjavascriptsame section
List databases
Show visible databases in the deployment.
OpenIn sheetjavascript1 tag match
Switch database
Change the current database context.
OpenIn sheetjavascript1 tag match