The new MongoDB Shell is GA!

The new MongoDB Shell (mongosh) is now GA and becomes the default shell for the MongoDB platform. Download it now and start using it right away.

Like all software we build at MongoDB, a great user experience is a major consideration. Even when working with a command-line tool, we believe it is just as important. To deliver this great experience to our users, we have redesigned the MongoDB Shell from the ground up to provide a modern command-line experience with enhanced usability features and a powerful scripting environment.

After 1 year in beta, with a lot of great feedback from users and customers, we are excited to announce the general availability of the MongoDB Shell, the best way to work with your data and with your MongoDB deployments from the command line.

The new MongoDB Shell is compatible with MongoDB 4.0+, so you don’t have to wait to upgrade to MongoDB 5.0 to start using it. You can download it and try it out now!

Enhanced user experience

To make queries and aggregations easier to write and results easier to read, the MongoDB Shell comes with syntax highlighting. Now, it’s much easier to distinguish fields, values, and data types, which helps avoid syntax errors.

If an error still occurs, the shell points you to the problem and helps you understand how to fix it.

To help you type your queries and commands faster, the new MongoDB Shell includes intelligent autocomplete: based on the version of MongoDB you are connected to, the shell can suggest autocomplete options for methods, commands, and even MQL expressions.

And when you don’t remember the syntax for a command, you can quickly look it up directly from the shell.

Advanced scripting environment

The MongoDB Shell is a great scripting environment. It’s built on top of the Node.js REPL, which means you can use the entire Node.js API in your scripts. Not only that: in your scripts for the MongoDB Shell you can now use any modules from npm.

In the video below, you can see how I used node-fetch to fetch some data from a REST API and store it in MongoDB.

Of course, you can also load and run scripts from the filesystem: as with the legacy mongo shell, in mongosh you can keep using load and eval to execute your scripts.

Extensibility and snippets

One of the goals we set for ourselves when we started building a new MongoDB Shell, was to make it easy to extend. This way, as the MongoDB platform grows with new products and services, the shell can grow with it.

We also wanted to give our users and customers the possibility to extend the shell with all the functionality they need to be productive with MongoDB. While that has somewhat always been possible by loading scripts at startup with an RC file, we decided to take it one step further.

In mongosh, we allow you to install Snippets. Snippets are plugins that you can install and are automatically loaded into the shell. Snippets can use any Node.js API and npm packages, allowing you to support a wide variety of use cases.

We maintain a repository with a few Snippets that offer some new, interesting functionality (e.g. a snippet to analyze the schema of a given collection) but you are free to configure mongosh to use a registry of snippets of your choice.

Snippets are currently an experimental feature of mongosh. We are curious to see how you use it and get feedback so we can take it in the right direction and help you customize the shell exactly the way you need it.

What happens with the legacy Mongo shell?

You might be wondering what will happen with the legacy mongo shell. We are not taking it away quite yet. However, starting with MongoDB 5.0 the legacy shell is deprecated, and we encourage you to switch to mongosh as your default shell.

Get started with mongosh!

The new MongoDB Shell is available in our download center. Install it, connect with a MongoDB cluster and start scripting! Learn more about the MongoDB Shell and how to use it in our online documentation. If you have feedback or if you would like to suggest new features please let us know through our feedback engine.