The most popular document database for modern applications
A source-available document database that stores data as flexible BSON documents instead of rigid relational tables.
Teams pick it when the schema changes often and they want a JSON-native store with built-in sharding and replication.
| Category | Document |
| First released | 2009 |
| Latest release | 8.3 (May 2026) |
| License | SSPL |
| Written in | C++, JavaScript |
| Runs on | Linux, Macos, Windows |
| Deployment | Self-hosted, Managed, Serverless |
| Wire protocol | mongodb |
| Query dialect | mql |
| Consistency | tunable |
| ACID support | native |
| JSON support | native |
| Full-text search | native |
| Vector support | native |
| HA model | raft |
| Managed by | mongodb-atlas |
MongoDB is a document database that stores data as JSON-like documents called BSON, a binary superset of JSON with extra types like ObjectId, dates, and 128-bit decimals. Instead of splitting related data across rows in different tables, you keep it together in a single document. That maps naturally to the objects an application already works with, so an order and its line items can live in one place, ready to read in a single query.
The engine started in 2007 at 10gen, a small ad-tech company that needed a database that could scale writes across cheap commodity servers. 10gen open-sourced it in 2009, dropped the ad-tech work to focus on the database, and renamed to MongoDB, Inc. The company went public in 2017. In 2018 it switched the server license from AGPL to the Server Side Public License, or SSPL, which the OSI does not accept as open source. That change kept AWS, Google, and other cloud providers from offering hosted MongoDB directly.
MongoDB became the default document database of the 2010s. Adobe, eBay, Forbes, Electronic Arts, Toyota, and Coinbase all run it in production. Atlas, the company's own managed service, is available on AWS, Azure, and GCP, and now generates most of MongoDB's revenue. On DB-Engines it consistently ranks as the most popular NoSQL database by a wide margin.
MongoDB is a client-server database. The mongod process listens on TCP port 27017 by default and speaks a binary wire protocol built on BSON. Drivers exist for most languages, and every driver knows how to route reads to secondaries, retry on failovers, and pool connections. Unlike Postgres, MongoDB uses a single multi-threaded process, so a busy server does not fork thousands of backend processes and does not need an external pooler.
Queries take one of two shapes. The find command runs a predicate against a collection and returns matching documents, using indexes when available. The aggregation pipeline chains stages like $match, $group, $lookup, and $project into a single query that can do joins, transformations, and analytics inside the server. A query planner picks the best plan based on collection statistics and cached winners from earlier runs.
Storage is handled by WiredTiger, a document-level MVCC engine that compresses on disk with Snappy or Zstd. Durability comes from a write-ahead journal. High availability lives in the replica set model, where a primary and two or more secondaries elect a new primary through Raft when the current one fails. Horizontal scale comes from sharding, which splits a collection across nodes by a shard key and lets a query router called mongos fan reads out to the right shards.
MongoDB stores data as BSON documents, a binary format that extends JSON with types like ObjectId, ISODate, and 128-bit Decimal. Each document is up to 16 MB and can hold nested objects and arrays. Documents skip the table-and-row rewrite most apps do at the ORM layer, so what you store looks like what you read.
A collection is a bucket of documents, roughly analogous to a table in SQL. Collections live inside databases, and a single mongod can host many of them at once. They do not enforce a schema by default, though you can attach a JSON Schema validator to reject documents that do not match the shape you expect.
MongoDB supports B-tree indexes on any field, including fields nested inside subdocuments and arrays. On top of those it ships compound, text, geospatial 2dsphere, TTL, wildcard, and vector search indexes. An index can cover fields the app only reaches through a nested path, which is normal for document data.
Instead of SQL, MongoDB runs analytics through a pipeline of stages. Each stage transforms the documents flowing through it: $match filters, $group aggregates, $lookup joins another collection, $project reshapes, and $unwind flattens arrays. The whole pipeline runs inside the server, close to the indexes.
Every production MongoDB runs as a replica set: a primary that takes writes and secondaries that stream the oplog and apply it in order. If the primary fails, a Raft election picks a new one within seconds. Reads can be routed to the secondaries, so read-heavy apps scale their reads without much extra work.
For datasets bigger than a single machine, MongoDB shards a collection across nodes by a shard key. A mongos router sits in front and directs each query to the shards that hold the matching data. The shard key is the most consequential choice in a cluster, since a poor one causes hot chunks and lopsided load.
Live GitHub adoption, updated daily
A handful of the companies running it in production
Products, articles, and user profiles each carry different fields. Documents let you store exactly what an item has, instead of forcing every row into the one fixed schema a table demands.
The aggregation pipeline runs multi-stage analytics inside the database, and change streams push updates to subscribers as they happen, so dashboards stay current without a second pipeline.
Small documents map cleanly onto the objects an app already uses, drivers exist for every mobile language, and sharding scales writes across many devices with no redesign of the schema.
Atlas Vector Search keeps embeddings and their metadata in the same collection as your application data, so retrieval-augmented generation reads from one database at query time, not two.
MongoDB has $lookup, but a schema with many foreign keys and cross-table constraints runs faster and cleaner on Postgres or MySQL, where multi-way joins are the native operation, not an add-on.
ClickHouse, BigQuery, and Snowflake are built for scan-heavy analytics over billions of rows, and beat it by an order of magnitude there. MongoDB can run the query, but it is the wrong tool.
MongoDB serves reads in the low single-digit milliseconds. If you need sub-millisecond reads for a session store or rate limiter, an in-memory store like Redis or Memcached wins on the same box.
MongoDB moved from the AGPL to the SSPL in 2018, which the OSI does not accept as open source. If your policy needs an OSI-approved license, use Postgres or the compatible FerretDB fork instead.
Head-to-head specs against the top 5 alternatives
| Spec | ||||||
|---|---|---|---|---|---|---|
| Identity | ||||||
| License | SSPL | PostgreSQL License | Proprietary | GPLv2 | Apache-2.0 | RSALv2 / SSPLv1 / AGPLv3 (triple-licensed) |
| First released | 2009 | 1996 | 2012 | 1995 | 2008 | 2009 |
| Capabilities | ||||||
| Schema | Schema-less | Strict | Schema-less | Strict | Strict | Schema-less |
| ACID | Native | Native | Native | Native | Compatible | Compatible |
| JSON | Native | Native | Native | Native | Native | Native |
| HA model | Raft | Primary-standby | Multi-master | Multi-master | Multi-master | Primary-standby |
| Ecosystem | ||||||
| Managed providers | 1 | 9 | 1 | 8 | 3 | 6 |
| ORM support | 6 | 10 | 2 | 8 | 2 | 4 |
| Use cases | ||||||
| Best for | Flexible-schema applications, content management, real-time analytics, and mobile/IoT backends | General-purpose OLTP, complex queries with advanced SQL, geospatial data with PostGIS, and applications requiring strong ACID compliance | Serverless applications, high-throughput key-value access patterns, and globally distributed low-latency workloads | Web applications, SaaS platforms, and high-throughput OLTP workloads | High-availability, write-heavy workloads requiring linear scalability across multiple data centers and regions | High-performance caching, session management, real-time leaderboards, rate limiting, pub/sub messaging, and AI vector search |
| Not ideal for | Highly relational data with complex joins or strict referential integrity requirements | Extreme write-heavy workloads at massive horizontal scale, simple key-value caching, or real-time streaming without extensions | Complex relational queries, ad-hoc analytics, or workloads requiring flexible querying without predefined access patterns | Complex analytical queries or workloads requiring advanced SQL features like CTEs with recursive optimization | Ad-hoc queries with complex joins, small-scale deployments, or workloads requiring strong ACID transactions | Complex relational queries, large datasets exceeding available memory, or workloads requiring strong multi-key ACID transactions |
Install MongoDB locally, connect with mongosh, and insert a first document. Under a minute if you have Docker.
docker run --name mongodb -p 27017:27017 -d mongo:8# macOS
brew tap mongodb/brew && brew install mongodb-community@8
brew services start mongodb-community@8
# Ubuntu/Debian
sudo apt install -y mongodb-org && sudo systemctl start mongodmongosh mongodb://localhost:27017use myapp;
db.users.insertOne({
email: "[email protected]",
createdAt: new Date(),
});
db.users.find();That is a working install. Drivers exist for every major language, and mongosh gives you a full JavaScript shell for ad-hoc work.
The world's most advanced open-source relational database
High-performance open-source vector database for next-generation AI applications
Fast in-process analytical database with rich SQL support and zero dependencies
In-process SQL database compatible with SQLite, written in Rust with vector search and CDC support
Fast, typo-tolerant open-source search engine with built-in vector and semantic search
Serverless PostgreSQL with separated storage and compute, branching, and scale-to-zero
Connect to MongoDB in 30 seconds. Browse tables, run queries, and edit rows visually, on localhost, self-hosted, or cloud.
Open MongoDB in 1bench