Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

MongoDB Playground (Queries & Aggregation Pipelines)

Test find() and aggregate() on your documents, stage by stage, without a database server.

Free preview, no sign-upIncluded in your pass Pro tool Pro pass: ₹179 / $5.99 for 30 days On this device: nothing is sent
+3 +1 more details No uploadWorks offline once opened Developer

Free preview: your queries on your documents: up to 5 query results in this tab, each with its document count and first documents (up to 10; one with its values hidden). Locked until you unlock it: download and copy.

Pro pass ₹179 for 30 days or ₹79 for 1 week, one‑time. Pro pass $5.99 for 30 days or $2.99 for 1 week, one‑time. How to unlock

Try before you buy.

  • Free preview: your queries on your documents: up to 5 query results in this tab, each with its document count and first documents (up to 10; one with its values hidden).
  • Locked until you unlock it: download and copy.
  • Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Query results unlock with a pass only. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews. Query results unlock with a pass only.

Ways to unlock shows how to get the full result.

See passes (opens in a new tab)

Printing this result is locked in the free preview.

Collections

    A JSON array, one document a line (mongoexport, JSON Lines), Extended JSON or mongosh syntax such as ObjectId("…"), ISODate("…") and NumberDecimal("…"). A whole db = { name: [ … ] } configuration makes one collection each.

    Options for CSV files

    Playground file

    Keeps your collections and the query in one file on your device, to open here again; nothing is stored online.

    Ctrl+Enter (⌘+Enter) runs the query. A bare filter { … } or pipeline [ … ] runs on the collection chosen on the left. Esc, then Tab, leaves the editor.

    The query in mongosh, Node.js and Python
     

    Results

    Loading the example shop…

    Next steps Done. What next?

    Start over

    A Pro pass unlocks the full result. See passes

    All developer tools

    About the MongoDB Playground (Queries & Aggregation Pipelines)

    Try MongoDB queries without installing or connecting to a database. Paste documents or open files — a JSON array, JSON Lines, mongoexport or Extended JSON output, a CSV file, or a .bson file from mongodump — into one or more named collections, then run find() with a filter, projection, sort, skip and limit, or an aggregate() pipeline, written the way you write it in mongosh. Read the results as a tree, a table or JSON, and see what every stage of a pipeline outputs, with a plain-English explanation of each step.

    The query engine is built into the page and follows the MongoDB manual: dotted paths that reach into arrays, $elemMatch, $lookup between your collections, $group with exact NumberDecimal sums, $unwind, $facet, $bucket, $setWindowFields and more than 150 expression operators, with BSON types kept (an int stays an int, a long stays a long). Each query is also written as mongosh, Node.js and Python (PyMongo) code. Everything runs in a worker on your device: nothing is uploaded, and Stop ends a runaway query.

    Without a pass the playground is a free preview: every query runs in full, and this tab shows 5 query results, each with its document count and its first documents. With a Pro pass every result shows in full and pages through, and the JSON view, JSON, JSON Lines, CSV and Excel downloads, copying, and the whole-file .bson and CSV conversion unlock.

    How to use it

    1. Start with the example shop (orders, customers and products), or paste your documents into Documents and give the collection a name. Open files makes one collection from each JSON, CSV or .bson file; New collection adds another for $lookup.
    2. Write the query: db.orders.find({ status: "pending" }).sort({ placedAt: -1 }), db.orders.aggregate([ … ]), countDocuments() or distinct() — or just a filter { … } or a pipeline [ … ] for the chosen collection. Example queries has ready-made ones.
    3. Press Run or Ctrl+Enter (⌘+Enter). For a pipeline, each stage shows how many documents it outputs and what it does; Show output shows the documents after that stage.
    4. Switch between Tree, Table and JSON, and open The query in mongosh, Node.js and Python to copy it into your code with a pass. The free preview shows the first documents of 5 query results in this tab; a pass unlocks every result, the JSON view and the downloads.
    5. Press Save playground to keep the collections and the query as a file, and Open playground to carry on later.

    Examples

    Revenue per customer, with $lookup
    Input
    db.orders.aggregate([
      { $match: { status: { $ne: "cancelled" } } },
      { $group: { _id: "$customerId", revenue: { $sum: "$total" } } },
      { $lookup: { from: "customers", localField: "_id", foreignField: "_id", as: "customer" } },
      { $unwind: "$customer" },
      { $project: { _id: 0, name: "$customer.name", revenue: 1 } },
      { $sort: { revenue: -1 } }
    ])
    Result
    { revenue: Decimal128('99.50'), name: 'Mia Chen' }
    { revenue: Decimal128('78.60'), name: 'Ana Costa' } …

    On the example shop. Each stage shows its document count — 7 orders after $match, 4 customers after $group — and what it does in plain English.

    An element that meets two conditions
    Input
    db.inventory.find({ instock: { $elemMatch: { qty: { $gt: 10, $lte: 20 } } } })
    Result
    journal, paper and postcard: each has one instock entry with a qty between 11 and 20.

    Without $elemMatch, { "instock.qty": { $gt: 10, $lte: 20 } } also matches planner, whose quantities 40 and 5 meet one condition each — the same results the MongoDB manual lists for its inventory example.

    The same query in Python
    Input
    db.orders.find({ status: "pending" }, { number: 1, total: 1 }).sort({ total: -1 }).limit(5)
    Result
    list(
        db["orders"].find({"status": "pending"}, {"number": 1, "total": 1}).sort([("total", -1)]).limit(5)
    )

    Node.js gets { projection: … } as the driver wants it; ObjectId, ISODate and NumberDecimal values come with their imports.

    Common uses

    • Working out an aggregation pipeline step by step before putting it in an application, with the output of every stage in view.
    • Answering a question about a mongoexport or mongodump file without restoring it into a database.
    • Learning MongoDB queries — arrays, embedded documents, $lookup, $group, window functions — on the example shop or your own data.
    • Turning a mongosh query into Node.js or PyMongo code, with the right imports for ObjectId, dates and decimals.
    • Converting a .bson dump or a CSV file into Extended JSON or JSON Lines, with a pass.

    What runs here

    • Queries: find(), findOne(), countDocuments(), count(), estimatedDocumentCount(), distinct() and aggregate(), with .sort(), .skip(), .limit(), .project() and .count(); db.getCollection("name") for names with dots; db.aggregate([{ $documents: … }]).
    • Filters: $eq $ne $gt $gte $lt $lte $in $nin $exists $type $regex (options i, m, s, x) $not $elemMatch $size $all $mod $and $or $nor $expr and the four $bits… operators, with dotted paths into arrays and array positions (items.0.qty).
    • Projections: inclusion, exclusion, $slice, $elemMatch, the positional $ and aggregation expressions.
    • Stages: $match $project $addFields $set $unset $group $sort $limit $skip $count $unwind $lookup (both forms) $graphLookup $facet $bucket $bucketAuto $sortByCount $replaceRoot $replaceWith $sample $unionWith $redact $setWindowFields $fill $documents, and $out and $merge into a collection of the playground.
    • Expressions: arithmetic (int and long overflow as MongoDB does; NumberDecimal exact), comparison, boolean, conditional ($cond, $switch, $ifNull), strings ($concat, $substrCP, $split, $regexMatch, $replaceAll …), arrays ($filter, $map, $reduce, $slice, $sortArray, set operators …), objects, type conversion ($convert, $toInt …) and dates with time zones ($dateToString, $dateTrunc, $dateAdd, $dateDiff …).
    • Accumulators: $sum $avg $min $max $first $last $push $addToSet $count $stdDevPop $stdDevSamp $mergeObjects $top $bottom $topN $bottomN $firstN $lastN $maxN $minN $median $percentile.

    What does not run, and why

    • JavaScript: $where, $function and $accumulator run JavaScript on a server; the playground never runs JavaScript, so they are switched off with a message. Write the logic with $expr, $cond, $map and $reduce.
    • Indexes and servers: $text and $meta (text search), $search, $searchMeta and $vectorSearch (server search indexes), $geoNear and the geospatial query operators, explain(), hint() (ignored), collations, $collStats, $indexStats, $currentOp, change streams and transactions.
    • Not built yet: $densify, $jsonSchema, granularity in $bucketAuto, and $derivative, $integral and $covariancePop in $setWindowFields.
    • Writes: insertOne(), updateMany(), deleteOne() and the like are refused: change documents in Documents, or write a result into a collection with $out or $merge.
    • $percentile and $median with method approximate are computed exactly here (a value of the input, as discrete), so they can differ slightly from a server’s estimate on large inputs.

    Types, files and Extended JSON

    • Documents are read as mongosh reads them: unquoted keys, single quotes, comments, trailing commas, /regex/i, and ObjectId(), ISODate(), new Date(), NumberInt(), NumberLong(), NumberDecimal(), Timestamp(), BinData(), UUID(), MinKey(), MaxKey() — and Extended JSON v2 ({"$oid": …}, {"$date": …}, {"$numberDecimal": …}), canonical or relaxed.
    • A whole number in a document is an int (a long once it is too big), as the drivers store it; write Double(5) or {"$numberDouble": "5"} for a double.
    • .bson files from mongodump are decoded by the BSON specification, every type included (DBPointer becomes { $ref, $id }). The .metadata.json files beside them hold indexes and are skipped.
    • CSV files are read like mongoimport: the first row names the fields, address.city makes a nested field, numbers become numbers (codes with leading zeros stay text), true and false become booleans, and ISO dates become dates (an option).
    • Exports are Extended JSON: relaxed, as mongoexport writes it, or canonical, which reads back with every type exact.

    Limitations

    • Collections live in this page’s memory; they are gone when you close or reload it unless you save the playground as a file.
    • Files up to 200 MB each; a large file needs several times its size in memory, which phones may not have.
    • A query is stopped after 20 seconds; collections written by $out or $merge are then cleared, and the rest are loaded again.
    • The tree and the table show 50 documents a page, and the table up to 300 columns; the JSON downloads hold every document.

    Privacy

    On this device: nothing is sent

    Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

    Frequently asked questions

    What do I get without a pass?

    Without a pass, MongoDB Playground (Queries & Aggregation Pipelines) shows your queries on your documents: up to 5 query results in this tab, each with its document count and first documents (up to 10; one with its values hidden). Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.

    Are my documents uploaded?

    No. The documents, the files and the queries stay in your browser; the query engine runs in a worker on your device.

    Is this the real MongoDB server?

    No. It is a query engine written for the browser that follows the MongoDB manual — the comparison and sort order of BSON types, the way paths reach into arrays, and the results of the manual’s own examples, which its tests check. A server can still differ in edge cases; what does not run here is listed above.

    Which free preview do I get?

    Every query runs in full on your documents. This tab shows 5 query results, each with its document count and its first documents (up to 10; a result of one document shows its field names, with the values hidden), the first lines of the query as code, and the plain-English explanation of every stage. A pass shows every result in full and unlocks the JSON view, paging and the downloads.

    How do I open a mongodump folder?

    Choose or drop the .bson files (one for each collection) from the dump folder; each becomes a collection named after its file. Gzipped dumps (--gzip, .bson.gz) need to be unpacked first.

    Can I save my work?

    Yes: Save playground writes the collections — as you typed them, or the files you opened — and the query into one file on your device, at any time. Open playground loads it again.

    Quick answers and tool search

    Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.