MongoDB Compass
Parent: MongoDB Expert Knowledge · researched 2026-05-29T14:10:40.176Z· 22 sources · 14 concepts · skill mongodb-compass
MongoDB Compass is the official, free, source-available GUI for MongoDB. It provides visual tools for querying, aggregating, analyzing, and managing MongoDB data without requiring command-line experti
MongoDB Compass — Expert Reference
- MongoDB Compass is the official, free, source-available GUI for MongoDB. It provides visual tools for querying, aggregating, analyzing, and managing MongoDB data without requiring command-line expertise, while still exposing an embedded mongosh shell for power users. Current stable release: 1.49.8 (May 27, 2026). [source]
When to Use This Skill
- User asks how to use, configure, or troubleshoot MongoDB Compass [source]
- Questions about schema analysis, explain plans, aggregation pipeline building, or index management in a GUI context [source]
- Advising on Compass editions for restricted or air-gapped environments [source]
- Evaluating query performance visually via explain plan trees [source]
- Using NLQ / AI-powered query generation in Compass [source]
- Compass plugin development or extensibility questions [source]
- Production safety guidance: what not to do with Compass against live clusters [source]
- Data modeling ER diagrams in Compass [source]
- Importing or exporting data via the Compass GUI [source]
When NOT to Use This Skill
- Questions about the MongoDB driver API or programmatic query construction → use [[mongodb-expert]] or [[mongodb-developer]] [source]
- Deep query optimization requiring profiler analysis or system.profile → use [[mongodb-query-performance]] [source]
- Atlas-specific cluster configuration, networking, or billing → use [[mongodb-atlas-expert]] [source]
- mongodump / mongorestore / mongoimport / mongoexport CLI tools (not Compass GUI) → use [[mongodb-backup-restore]] [source]
- MongoDB shell (mongosh) scripting beyond what the embedded shell covers → use [[mongodb-expert]] [source]
1.1 Editions
- Compass ships in two active editions (Readonly Edition is being deprecated): [source]
- Compass (Full): The standard edition with all features including AI-powered NLQ, automatic updates, and telemetry. Free and source-available. [source]
- Compass Isolated Edition: Designed for air-gapped or high-security environments. All network connections except the MongoDB server are blocked - no telemetry, no AI features, no auto-update checks, no additional firewall configuration required. Use when data residency or network egress policies prohibit external calls. [source]
- Compass Readonly Edition (DEPRECATED): Historically limited to read operations. Will be removed in a future release. To achieve read-only behavior in the current edition: [source]
- Assign users the built-in read role at the database level in MongoDB. [source]
- Enable the readOnly option in Compass Settings. [source]
- > Warning: The readOnly Compass setting only hides write-operation UI elements; it does not enforce restrictions at the driver level for shell commands typed in the embedded mongosh. [source]
1.2 Connection String Builder
- Compass provides a visual connection form that builds connection strings without manual URI syntax knowledge: [source]
- General tab: hostname, port, authentication (username/password, X.509, LDAP, Kerberos, AWS IAM, OIDC) [source]
- TLS/SSL tab: CA certificate, client certificate/key, allow invalid hostnames [source]
- Proxy/SSH tab: SOCKS5 proxy, SSH tunnel configuration [source]
- Advanced tab: replica set name, read preference, authentication database, server selection timeout, directConnection flag [source]
- The built connection string is displayed and editable directly for power users who prefer URI syntax. [source]
1.3 Connection Favorites and Color Coding
- Save any connection as a favorite for quick access: [source]
- Favorites always appear at the top of the connections sidebar. [source]
- Each favorite can be assigned a color label. When connected, that color becomes the background of all tabs belonging to that connection - making it immediately clear which environment (dev/staging/prod) you are on. [source]
- Favorites can be edited (name, color, credentials) from the connections sidebar context menu (⋯ icon). [source]
- Favorites are stored with credentials in the OS keychain (macOS Keychain / Windows Credential Manager / GNOME Keyring on Linux). [source]
- Import/export favorites via JSON for team sharing or backup. [source]
- As of v1.44.5, you can edit name, color, and favorite status while actively connected. [source]
1.4 Multiple Simultaneous Connections
- Since Compass 1.36+, you can connect to multiple MongoDB deployments simultaneously in separate tabs, each color-coded by their favorite label. [source]
1.5 Key URI Parameters (Advanced Tab)
- The Advanced tab of the connection form exposes these commonly needed URI parameters: [source]
2.1 Overview
- The Schema tab infers the shape of a collection by sampling documents and presenting interactive visualizations of field types, value distributions, and cardinality - without writing any code. [source]
2.2 Sampling Mechanics
- Default sample size: 1,000 documents drawn using MongoDB's $sample aggregation operator. [source]
- Sampling works over the entire collection or a filtered subset when a query is entered in the query bar. [source]
- A random, non-replacement sample is used; results approximate full-dataset analysis for most distributions. [source]
- To increase the sample size beyond 1,000, go to Compass Settings → General and change the "Sample Size" field (default 1000). The query bar's Options → MAX TIME MS controls the query execution timeout (default 60,000 ms) - a separate setting that does not affect sample size. [source]
- Compass shows a warning when the collection has > 1,000 documents, indicating results reflect only the sampled subset. [source]
2.3 Field Type Distribution
- For each field, Compass shows: [source]
- Single data type: type name with min/max/mean statistics. [source]
- Multiple data types: percentage breakdown pie/bar (e.g., 20% int32, 80% string) - useful for spotting type inconsistencies in schemaless collections. [source]
- Missing/undefined: percentage of documents that do not contain the field at all - critical for identifying optional vs. required fields. [source]
- Nested documents and arrays: expandable to show nested field analysis, plus min/max/average array lengths. [source]
2.5 Interactive Query Building from Schema
- Clicking on chart values generates query filter predicates automatically: [source]
- Click a bar in a string histogram → adds {"field": "value"} to the query bar. [source]
- Click+drag over a numeric histogram range → adds {"field": {$gte: X, $lte: Y}}. [source]
- Draw a circle on a geo map → adds a $geoWithin / $geometry polygon filter. [source]
- Shift+click for multi-select; multiple fields combine with $and. [source]
2.6 Use Cases
- Data quality assessment: spot missing fields, unexpected type mixing, outlier values. [source]
- Cardinality analysis: determine selectivity before creating indexes. [source]
- Range identification: find min/max for numeric bounds and TTL candidates. [source]
- Index candidate identification: high-cardinality fields with frequent query patterns. [source]
- Data modeling validation: verify that actual data conforms to intended schema. [source]
- Geographic data exploration: visualize point distributions for location-based collections. [source]
2.7 Schema Export
- Use the Schema Export feature (linked from the Schema tab) to export the inferred schema as JSON for documentation, sharing with teams, or importing into other tools. [source]
3.1 Overview
- The Aggregations tab provides a visual, stage-by-stage builder for MongoDB aggregation pipelines. Each stage displays a live preview of its output from sampled data, making it easy to iterate on complex transformations. [source]
3.2 Pipeline Creation Modes
- Stage View Mode (default): Visual pipeline editor. Each stage appears as a card with: [source]
- Stage type dropdown [source]
- Stage configuration editor with syntax highlighting and autocomplete [source]
- Output preview panel showing up to 10 sampled documents from the stage's output [source]
- Stage Wizard (within Stage View): Click the wand icon to get templates for common stages: $group, $lookup, $match, $project, $sort. The wizard generates boilerplate code to fill in. [source]
- Focus Mode (within Stage View): Edit one stage at a time with a full-height view showing Stage Input, editor, and Stage Output side by side. Ideal for complex or deeply nested stages. Keyboard shortcuts: Cmd+Shift+A (add stage after), Cmd+Shift+B (add stage before), Cmd+Shift+9/0 (navigate between stages). [source]
- Text View Mode: Raw text editor accepting full pipeline JSON/EJSON syntax with real-time linting. Toggle the </> switch to enter this mode. [source]
3.3 Stage Management
- Add stage: Click + Add Stage at the bottom, or + above any existing stage card. [source]
- Toggle stage on/off: Use the toggle switch on the stage card header to include/exclude a stage without deleting it - useful for A/B testing pipeline behavior. [source]
- Reorder stages: Drag the stage card header to a new position. [source]
- Delete stage: Click the trash icon on the stage card. [source]
- Resize stage editor: Drag the stage card border to adjust width. [source]
3.4 Stage Preview
3.5 Atlas Search Stages
3.6 Export Pipeline to Language
- Click the Export to Language button to generate application-ready code in: [source]
- JavaScript (Node.js), Python, Java, C# (.NET), Ruby, Go, Rust, PHP [source]
- The generated code includes the driver boilerplate (collection reference, pipeline array, cursor iteration) so it can be dropped directly into an application. [source]
3.7 Saved Pipelines
- Save a pipeline: Click the Save button to name and save the pipeline for later use. [source]
- Open saved pipelines: Load previously saved pipelines from the pipeline list. [source]
- Saved pipelines are stored locally in Compass. [source]
- Tip: save in-progress pipelines before closing Compass; unsaved pipelines are lost on exit. [source]
3.8 Running and Exporting Results
4.1 Overview
- The Explain Plan (accessible from both the Documents query bar and the Aggregation Pipeline Builder) visualizes how MongoDB executes a query or pipeline, helping identify performance bottlenecks. [source]
4.2 View Formats
- Visual Tree View (default): Each execution stage appears as a clickable node in a hierarchical tree. Click any node to see detailed execution statistics for that stage. [source]
- Raw Output View: The full explain document shown as formatted JSON - equivalent to running db.collection.explain("executionStats") in the shell. [source]
- > Note: Visual Tree view is not available for vector search queries; use Raw Output view instead. [source]
4.3 Summary Metrics
4.5 Sharded Cluster Plans
- For sharded collections: SHARD_MERGE node at top, per-shard sub-plans, winning plan per shard. Use Raw Output for the full shards array with per-shard executionStats. [source]
4.6 How Compass Explain Differs from Shell Explain
- Compass runs executionStats verbosity by default (executes the query). [source]
- Compass omits $merge and $out from pipeline explains. [source]
- Compass adds a maxTimeMS cap (configurable since v1.49.6). [source]
- The shell supports allPlansExecution verbosity; only available via Raw Output in Compass. [source]
4.7 Workflow: Explain-Driven Index Creation
- Run explain on a slow query. [source]
- Identify COLLSCAN (red) in the tree. [source]
- Note filter and sort fields. [source]
- Switch to Indexes tab (Section 5). [source]
- Create compound index: filter fields first, sort fields after. [source]
- Re-run explain → verify IXSCAN replaces COLLSCAN. [source]
- Check nReturned ≈ totalKeysExamined. [source]
5.1 Indexes Tab Overview
- > Usage statistics reflect only the connected node. For cluster-wide stats: db.collection.aggregate([{$indexStats: {}}]). [source]
5.2 Creating Indexes
- Index types per field: Ascending (1), Descending (-1), 2dsphere, Text. Add fields with + for compound indexes. [source]
5.3 Hiding and Unhiding Indexes
5.4 Dropping Indexes
- Click trash icon → enter exact index name → Drop. The _id index cannot be dropped. Never drop indexes on live production without first hiding them (see Section 12, Anti-Patterns). [source]
5.5 Index Usage Statistics and Redundant Index Detection
5.6 Index Build Progress
- Background operation on large collections; progress shown in Indexes tab. Do not disconnect or kill mongod during a build. [source]
5.7 Queryable Encryption Limitation
- Do not create regular indexes on encrypted fields. Use __safeContent__ for Queryable Encryption equality queries. [source]
6.1 Performance Insights (Built-in Compass Feature)
- Automatic, no Atlas required: [source]
6.2 Atlas Performance Advisor
- When connected to Atlas: monitors queries >100ms, groups by query shape, calculates Impact score (AQT - docs scanned per doc returned; lower is better), detects prefix-redundant indexes. One-click index creation available in Atlas web UI. [source]
6.3 Workflow: Slow Query Remediation
- Performance Insights runs automatically. [source]
- Run typical queries via query bar or aggregation builder. [source]
- Observe Performance Insights banners. [source]
- Create recommended index in Indexes tab. [source]
- Re-run query and compare explain plan. [source]
- For Atlas: check Atlas UI Performance Advisor for cluster-wide analysis. [source]
7.1 Documents Tab Overview
- Query bar (filter, projection, sort, skip, limit, maxTimeMS, hint), three view modes, insert/export/count controls. [source]
7.2 Document View Modes
- List View (default): Key-value pairs, expandable nested objects/arrays. [source]
- JSON View: Full EJSON rendering. Editing performs findOneAndReplace - replaces the entire document. [source]
- Table View: Rows and columns; resizable columns (v1.49.0+). Editing performs findOneAndUpdate - modifies only changed fields. [source]
- > Critical: JSON view editing replaces the whole document. Use List or Table view for surgical field edits. [source]
7.3 In-Place Editing
- Double-click field → edit → checkmark to apply. List/Table view: findOneAndUpdate with $set. JSON view: findOneAndReplace. [source]
7.4 Document Insertion
- JSON Mode: paste array or single object. Field-by-Field Editor: interactive BSON type selection. [source]
7.5 Array and Subdocument Expansion
- Expandable inline in List view. ObjectIds auto-wrap when pasted (v1.49.0+). [source]
7.6 Projection Support
- {field: 1} include / {field: 0} exclude. Reduces noise and load time for large documents. [source]
7.7 Multi-Select Delete
- Checkboxes → Delete Selected → runs deleteMany on selected _id values. Irreversible. [source]
7.8 Schema Validation Rules (Validation Tab)
- The Validation tab (a separate tab adjacent to Documents, not inline editing) manages collection-level schema validation rules: [source]
- Supports $jsonSchema and MQL query operator syntax [source]
- validationLevel: strict (all inserts/updates) or moderate (new docs only) [source]
- validationAction: error (reject) or warn (accept with warning) [source]
- Generate Rules: auto-generates $jsonSchema from existing data [source]
- Preview documents: shows sample docs matching the validation expression [source]
8.1 Overview
- AI-powered interface generating MongoDB query syntax and aggregation pipelines from plain English. Remains labeled experimental in official documentation; v1.49.0 added tool-calling capability and removed the AI Assistant preview badge - always review generated queries before executing. [source]
8.2 Enabling NLQ
- Settings → Use Generative AI toggle. Requires internet; not available in Compass Isolated Edition. [source]
8.3 Generating Queries
8.4 Generating Aggregation Pipelines via NLQ
- Prompts requiring aggregation auto-redirect to the Aggregations tab with a generated pipeline. [source]
8.5 Privacy and Data Handling
- Prompt text and collection schema (field names/types - not document values) sent to Microsoft Azure OpenAI. Data not stored on third-party systems; not used to train AI models. [source]
8.6 Supported Input Types
- Natural language, pasted SQL (translated to MQL), application code snippets. [source]
8.7 Limitations and Caveats
- Experimental accuracy: always review before running. [source]
- Complex queries: multi-stage pipelines may produce incorrect results. [source]
- MAX TIME MS: increase for complex generated pipelines. [source]
- Review before executing: NLQ generates filter queries; risk arises from running filters with destructive intent (e.g., Delete Selected after filtering). [source]
- Schema required: works best when schema analysis has been run. [source]
8.8 Compass AI Assistant
- Since v1.49.0: chat interface (mongodb-chat-2 model) for Compass feature questions, query optimization, pipeline debugging, schema design guidance. Accessible from the Assistant panel (speech bubble icon). Tool-calling allows the assistant to execute Compass operations directly. [source]
9.1 Importing Data
- Documents tab → Add Data → Import File. Supported: JSON (array or NDJSON) and CSV (first row = field names; BSON type inference with manual override). For >10k documents, prefer mongoimport CLI - Compass import holds the full file in memory. [source]
9.2 Exporting Data
- Query results: filter → Export Collection → JSON or CSV [source]
- Aggregation results: Aggregations tab → Run → Export → JSON or CSV [source]
- Full collection: empty filter {} → Export Collection [source]
- > For large collections, use mongoexport/mongodump CLI - Compass export loads into memory before writing. [source]
9.3 Import/Export Limitations
10.1 Architecture: Electron + React
- Electron app (Chromium + Node.js), React UI, multi-package monorepo at github.com/mongodb-js/compass. Each feature is a separate npm package: [source]
- @mongodb-js/compass-crud, compass-schema, compass-indexes, compass-aggregations, compass-query-bar, compass-schema-validation, compass-collection, compass-instance [source]
10.2 `@mongodb-js/compass-components`
- Shared UI library wrapping LeafyGreen (MongoDB's React design system). Ensures visual consistency; single dependency update propagates across all plugins. [source]
10.3 Third-Party Plugin Development (Deprecated)
- Previously supported via compass-plugin khaos boilerplate (React + Reflux stores + Enzyme + Storybook). The external plugin API has been internalized; third-party development is no longer actively promoted. [source]
10.4 Custom Themes
- Light and dark mode supported. Custom theming beyond built-in modes is not officially supported. [source]
10.5 Compass as a Development Platform
10.6 Compass Shell (mongosh)
- Embedded mongosh access: click >_ next to connection name, or >_ Open MongoDB shell in any tab. Already connected; use for operations not available in GUI (db.adminCommand(), profiler control, etc.). [source]
11.1 Overview
- Since 2025, Compass includes Data Modeling - visual ER diagrams from existing collections for understanding, documenting, and planning schema structure. [source]
11.2 Generating a Diagram
11.3 Diagram Features
11.4 Export Formats
- Image (PNG/SVG), JSON (machine-readable), .mdm (Compass-native, reopenable in Compass) [source]
12.1 Connecting to Primary in Production Without Read Preference
12.2 Large Sample Sizes Causing OOM
12.3 Running Explain on Large Collections Without a Query Filter
- Anti-pattern: Explain on unfiltered {} against multi-million document collections. [source]
- Why it's harmful: executionStats verbosity executes the query; COLLSCAN on large collections takes minutes. [source]
- Fix: Add a narrow filter first. For planning-only analysis: db.collection.explain("queryPlanner") in shell. [source]
12.4 Leaving Compass Connections Open (Connection Limit Impact)
- Anti-pattern: Idle Compass connections left open overnight or across weekends. [source]
- Why it's harmful: Each connection counts against Atlas connection limits. As a rough guide: M0 ~500, M10 ~1,500, M20/M30 ~3,000 - verify current limits in the Atlas connection limits documentation. [source]
- Fix: Disconnect when not in use; one connection per cluster per user. [source]
12.5 Relying on Compass Usage Stats Alone for Index Decisions
- Anti-pattern: Using only the Usage column to decide which indexes to drop. [source]
- Why it's harmful: Usage counters reset on every mongod restart. Monthly-use indexes show zero after a failover. [source]
- Fix: Use $indexStats (includes accesses.since); cross-reference with Atlas Performance Advisor. [source]
12.6 Editing Documents in JSON View Accidentally (findOneAndReplace)
12.7 Using Compass on Encrypted Fields Without Understanding Queryable Encryption Limits
13.1 Performance Tab
- Access: connection context menu (⋯) → Performance. [source]
13.2 Killing Slow Operations
- Slowest Operations panel → Operation Details → Kill Op. Requires killop privilege for operations you don't own. [source]
13.3 Pause and Resume
- Pause stops display refresh without stopping data collection. Play resumes. [source]
13.4 Limitations
Official Documentation
- MongoDB Compass Overview [source]
- Compass Editions [source]
- Schema Analysis [source]
- Sampling [source]
- Aggregation Pipeline Builder [source]
- View Query Performance [source]
- Manage Indexes [source]
- Performance Insights [source]
- Analyze Slow Queries (Atlas) [source]
- View Documents [source]
- Modify Documents [source]
- NLQ Enable [source]
- NLQ Prompt Query [source]
- Set Validation Rules [source]
- Real-Time Performance [source]
- Data Modeling [source]
- Favorite Connections [source]
- Release Notes [source]
Related Skills
- [[mongodb-expert]], [[mongodb-atlas-expert]], [[mongodb-indexes-deep]], [[mongodb-query-performance]], [[mongodb-aggregation-pipeline]], [[mongodb-schema-design]], [[mongodb-performance-troubleshooting]] [source]
Children
- Compass Editions (frontier)
- Compass Connection Management (frontier)
- Compass Schema Analysis (frontier)
- Compass Aggregation Pipeline Builder (frontier)
- Compass Explain Plan Visualizer (frontier)
- Compass Index Management (frontier)
- Compass Performance Insights (frontier)
- Compass CRUD and Documents Tab (frontier)
- Compass Natural Language Query (frontier)
- Compass Data Import Export (frontier)
- Compass Plugins and Extensibility (frontier)
- Compass Data Modeling ER Diagrams (frontier)
- Compass Anti-Patterns (frontier)
- Compass Real-Time Performance Monitoring (frontier)
Frontier under this node: Compass Aggregation Pipeline Builder, Compass Anti-Patterns, Compass CRUD and Documents Tab, Compass Connection Management, Compass Data Import Export, Compass Data Modeling ER Diagrams, Compass Editions, Compass Explain Plan Visualizer, Compass Index Management, Compass Natural Language Query, Compass Performance Insights, Compass Plugins and Extensibility, Compass Real-Time Performance Monitoring, Compass Schema Analysis