MongoDB Query Playground
Test MongoDB queries and aggregation pipelines on your own JSON without a database: mongosh syntax, $lookup between collections and per-stage results.
Se ejecuta en tu navegador. Tus archivos nunca salen de tu dispositivo. Cómo comprobarlo
…
Cómo hacerlo
- 1Add data
Paste documents into the collection box or use Import JSON files; add more collections with + Collection.
- 2Check the schema
Open the Schema tab to see field names, types and coverage.
- 3Write a command
Type a mongosh command or pick one from Examples.
- 4Run it
Press Run or Ctrl+Enter and read the count and timing line.
- 5Step through stages
Click a stage button to see the documents after that stage.
- 6Export results
Switch to Table, then copy, download JSON or CSV, or save the result as a collection.
Sobre esta herramienta
Writing an aggregation pipeline against a production database is a slow loop: edit, run, scroll, guess which stage went wrong. This playground runs a MongoDB-compatible query engine entirely in the browser on documents you paste or import. Type commands exactly as in mongosh, such as db.orders.find with a filter, sort and limit, or db.orders.aggregate with a list of stages, and press Ctrl+Enter. Aggregations show a button for every stage with the number of documents it produced, so you can step through $match, $unwind, $group and $project and see where your data takes an unexpected turn. Several collections live side by side, which makes $lookup joins testable. Updates and deletes change the in-browser copy only, and undo brings the data back, so it is a safe place to rehearse a risky updateMany.
Who this is for
Backend developers designing queries, analysts learning the aggregation framework, students preparing for MongoDB certification, and anyone debugging a pipeline from a bug report with sample documents.
Collections and data
Each collection is a text box that accepts a JSON array, JSON lines as written by mongoexport, or shell syntax with ObjectId(), ISODate(), NumberLong() and regular expressions. Extended JSON such as $oid and $date is converted, so exports from Compass or Atlas paste straight in. Import JSON files adds one collection per file. The Schema tab lists every field path with the types it holds and how many documents have it, which helps with messy data.
Queries
Supported methods: find with sort, skip, limit, count and explain; findOne; countDocuments; estimatedDocumentCount; distinct; aggregate; insertOne and insertMany; updateOne, updateMany with upsert, replaceOne; deleteOne, deleteMany and drop. Query operators include comparison, $in and $nin, $exists, $type, $regex, $size, $all, $elemMatch, $not, $mod, $and, $or, $nor and $expr, with dot paths and array matching as in the MongoDB manual.
Aggregation
Stages: $match, $project, $addFields and $set, $unset, $group, $sort, $limit, $skip, $unwind with includeArrayIndex and preserveNullAndEmptyArrays, $lookup with localField or a pipeline, $count, $sortByCount, $replaceRoot, $replaceWith, $facet, $bucket and $sample. Expressions cover arithmetic, comparisons, $cond, $ifNull, $switch, string and array operators including $filter, $map and $reduce, date parts and $dateToString, and type conversions. $round rounds half to even like MongoDB.
Results
View results as JSON or as a table, copy them, download JSON or CSV, or save a result as a new collection to chain experiments. The last 20 commands stay in the history list.
Worked example
With the sample orders, the pipeline $match status in paid and shipped, then $group by city summing total, then $sort by revenue gives Berlin 138.5, Paris 156 and so on. Stepping to stage 1 shows that 4 of 6 orders passed the match; switching $match to include pending adds Rome with 40.
Limits
This is an emulator, not the MongoDB server: there are no indexes, transactions, collations, text or geospatial search, $graphLookup or time-series features, and explain output is simplified. Numbers are JavaScript doubles, so NumberDecimal precision is not kept. Very large collections (hundreds of thousands of documents) can be slow in a browser tab.
Ejemplo práctico
$match paid or shipped → $group by city with $sum total → $sort revenue: Paris 156, Berlin 138.5; stage 1 shows 4 of 6 orders kept.
Datos rápidos
- Categoría: Desarrollo y datos
- Funciona en tu navegador, sin registro y sin subir nada.
- Lo que introduces se queda en tu dispositivo.
- Disponible en inglés.
- Contenido revisado por última vez:
- Fuente oficial: MongoDB Manual: operators reference
Preguntas frecuentes
Do I need a MongoDB server?
No. A query engine written in JavaScript runs in the page on the documents you paste.
Can I paste data exported from Compass or mongoexport?
Yes. JSON arrays, JSON lines and Extended JSON with $oid and $date are all read.
Does $lookup work?
Yes, between collections in the same workspace, with localField and foreignField or with let and a sub-pipeline.
Will updateMany change my real database?
No. Only the copy in this page changes, and Undo restores the previous data.
Why does my result differ from the server?
Edge cases such as collation, decimal precision or operators that are not implemented can differ. Check the list of supported operators in the page.
Where is my data kept?
In this browser's local storage. Use Save file to keep a copy or move it to another device.
