Introducing MongoDB for VS Code

Massimiliano Marcon


In the past few years, VS Code has grown in popularity and became the most used code editor for developers. Its extensibility makes it possible to customize the coding experience and tailor it to the languages, frameworks, and services developers use to build applications.

To make developers more productive when working with MongoDB, we built MongoDB for VS Code, an extension that allows you to quickly connect to MongoDB and MongoDB Atlas and work with your data to build applications right inside your code editor. With MongoDB for VS Code you can:

  • Connect to a MongoDB or Atlas cluster, navigate through your databases and collections, get a quick overview of your schema, and see the documents in your collections;
  • Create MongoDB Playgrounds, the fastest way to prototype CRUD operations and MongoDB commands;
  • Quickly access the MongoDB Shell, to launch the MongoDB Shell from the command palette and quickly connect to the active cluster.

MongoDB for VS Code is open-source under the Apache 2 license.


To install MongoDB for VS Code, simply search for it in the Extensions list directly inside VS Code or head to the “MongoDB for VS Code” homepage in the VS Code Marketplace.

Navigate your MongoDB Data

MongoDB for VS Code can connect to MongoDB standalone instances or clusters on MongoDB Atlas or self-hosted. Once connected, you can browse databases, collections, and read-only views directly from the tree view.

For each collection, you will see a list of sample documents and a quick overview of the schema. This is very useful as a reference while writing queries and aggregations.

MongoDB Playgrounds

MongoDB Playgrounds are the most convenient way to prototype and execute CRUD operations and other MongoDB commands directly inside VS Code.

Playgrounds are JavaScript environments where you can write MongoDB commands (with shell syntax) and see the results instantly. To make things easier, playgrounds include syntax highlighting and intelligent autocomplete for MongoDB shell API (e.g., find, aggregate, toArray), MongoDB operators, and for database, collection, and field names.

If you are still learning the aggregation syntax or simply want to type your stages quickly, MongoDB for VS Code helps you with well-commented code snippets that will get you going.

When you are building applications, playgrounds are helpful as a prototyping environment. For example, you can keep a playground open next to your application code and use it to test and iterate over your queries until you’ve found the ones you need.

Playgrounds can also be used as a quick way to seed a database with test data.

  1. Design your schema
  2. Define a few test documents or write a script that generates them in a MongoDB playground
  3. Save your playground file and check it into the code repository so everybody in your team is aligned on what the data looks like and can quickly generate test data in their test cluster.

Quick access to the MongoDB Shell

Sometimes, you need to go beyond what a UI can provide. Maybe you want to check on the status of the nodes in your cluster or verify the configuration of your production boxes.

MongoDB for VS Code lets you launch a MongoDB Shell and be connected to the active server or cluster in no time.

Automate Atlas configuration with Terraform

If you manage your infrastructure with Terraform, the MongoDB Atlas Terraform Provider is a great way to set up and configure your Atlas resources.

In MongoDB for VS Code, we added a snippet that helps you bootstrap your Terraform configuration for Atlas. Just open a Terraform file, type atlas, tab through the predefined placeholders, configure your credentials and you are good to go.

Try it now!

If you are a VS Code user, getting started with MongoDB for VS Code is easy:

  1. Install the extension from the marketplace;
  2. Get a free Atlas cluster if you don’t have a MongoDB server already;
  3. Connect to it and start building a playground.

You can find more information about MongoDB for VS Code and all its features in the documentation.

If you have any questions on MongoDB for VS Code, you can join in the discussion at the MongoDB Community Forums, and you can share feature requests using the MongoDB Feedback Engine.