MongoDB Compass
MongoDB Compass is the official GUI for MongoDB. It lets you explore your data, run queries, view performance metrics, build aggregation pipelines, and manage indexes — all without writing shell commands.
Installing Compass
# macOS — install with Homebrew Cask brew install --cask mongodb-compass # Or download the installer directly: # https://www.mongodb.com/try/download/compass
Go to mongodb.com/try/download/compass
Select your OS (Windows .exe, macOS .dmg, Linux .deb / .rpm)
Run the downloaded installer and follow the prompts
Launch MongoDB Compass from your Applications folder or Start Menu
Connecting to a Database
Open MongoDB Compass
Click "New Connection"
Paste a connection string or fill in the host/port/auth form
Click "Save & Connect"
Navigating the Interface
Panel | Purpose |
|---|---|
Databases view | Lists all databases with their storage sizes |
Collections view | Lists collections within the selected database |
Documents tab | Browse, filter, insert, edit, and delete documents |
Schema tab | Visualizes field types and value distributions from a sample |
Aggregations tab | Build and test aggregation pipelines visually |
Indexes tab | View, create, and drop indexes; shows index size and usage |
Explain Plan tab | Shows the query execution plan (IXSCAN vs COLLSCAN) |
Performance tab | Real-time server metrics: operations/sec, memory, network |
Viewing and Filtering Documents
Filter bar syntax (same as MongoDB query)
{ "age": { "$gt": 25 }, "status": "active" }The filter bar at the top of the Documents tab accepts any valid MongoDB query document. You can also add a Projection to show only specific fields, and a Sort to order results. All three fields use standard MongoDB JSON syntax.
The Schema Tab
Compass analyzes a sample of documents and visualizes the schema — field types, value distributions, minimum/maximum/average for numbers, and date ranges. Clicking on a chart segment automatically populates the filter bar with the corresponding query.
Building Aggregation Pipelines
Click the Aggregations tab for a collection
Click "Add Stage" and select a stage operator (e.g. $match)
Fill in the stage JSON in the editor panel
Add more stages as needed — the output preview updates live
Click "Export to Language" to generate Node.js, Python, Java, or C# driver code
Managing Indexes
The Indexes tab shows every index on the collection along with its size and usage statistics. You can create new indexes by clicking "Create Index" and entering the key specification, or drop unused indexes to free storage and improve write performance.
Creating an index in Compass
{ "email": 1 }After entering the key, check Unique to enforce uniqueness, or Sparse to exclude documents that lack the indexed field.
Explain Plan
The Explain Plan tab shows exactly how MongoDB executes a query. Look for IXSCAN (index scan — fast) versus COLLSCAN (collection scan — reads every document). The winning plan section shows which index was chosen and how many keys were examined versus how many documents were returned. A high keys-examined-to-returned ratio signals a poor index.