UnQTools
Developer Runs in your browser

MongoDB Aggregation Pipeline Builder

Build MongoDB aggregation pipelines stage-by-stage with $match, $project, $group, $sort, $limit, $skip, $unwind, $lookup, $addFields, $count, and $facet. Per-stage live preview on pasted sample documents. Accumulators ($sum, $avg, $push, $first, $last, $max, $min, $count) and expressions ($cond, $switch, $concat, $toUpper, $toLower, $add, $subtract, $multiply, $divide, $dateToString, $ifNull, $literal). Export pipeline JSON + driver code for mongosh, Node, Python, Java, C#, and PHP. Stage enable/disable toggle, drag-reorder, shareable URL, history. 100% client-side.

100% Private Works Offline Instant

About MongoDB Aggregation Pipeline Builder

Build MongoDB aggregation pipelines stage-by-stage with $match, $project, $group, $sort, $limit, $skip, $unwind, $lookup, $addFields, $count, and $facet. Per-stage live preview on pasted sample documents. Accumulators ($sum, $avg, $push, $first, $last, $max, $min, $count) and expressions ($cond, $switch, $concat, $toUpper, $toLower, $add, $subtract, $multiply, $divide, $dateToString, $ifNull, $literal). Export pipeline JSON + driver code for mongosh, Node, Python, Java, C#, and PHP. Stage enable/disable toggle, drag-reorder, shareable URL, history. 100% client-side. Everything runs locally in your browser — your data never leaves your device.

How to use

  1. Enter your input in the tool above.
  2. Adjust any options to your preference.
  3. Use the Copy or Download buttons to save the result.
  4. Everything happens locally — your data never leaves your browser.

FAQ

Which aggregation stages does this builder support?

Eleven stages: $match (MQL filter), $project (reshape/select fields), $group (group + accumulate), $sort, $limit, $skip, $unwind (explode arrays), $lookup (join another collection), $addFields (add computed fields), $count (count → single field), and $facet (parallel sub-pipelines). Each stage can be enabled/disabled for debugging and reordered via the up/down buttons.

What accumulators and expressions are supported?

Eight accumulators in $group: $sum, $avg, $push, $first, $last, $max, $min, $count. Twenty expressions: $cond, $switch, $concat, $toUpper, $toLower, $add, $subtract, $multiply, $divide, $dateToString, $ifNull, $literal, $eq, $ne, $gt, $lt, $gte, $lte, $and, $or. The in-browser engine evaluates them against your sample documents in real time.

Can I see what each stage does to my data?

Yes. Paste a JSON array of sample documents and the in-browser aggregation engine runs each stage in order, showing the document count and a row-level preview after every stage. Disabled stages pass through unchanged. The engine supports $match filtering, $project with expressions, $group with all accumulators, $sort, $limit, $skip, $unwind (with preserveNullAndEmptyArrays), $lookup (joins against the same sample docs), $addFields, $count, and $facet (with nested sub-pipelines).

What does the tool export?

Pipeline JSON (the array of stage objects), plus driver code for six targets: mongosh (db.coll.aggregate(...)), Node.js (MongoClient + .aggregate().toArray()), Python (PyMongo collection.aggregate(pipeline)), Java (Arrays.asList(Document.parse(...))), C# (.NET BsonDocument.Parse(...)), and PHP ($collection->aggregate($pipeline)). The exported pipeline runs unchanged against a real MongoDB.

What extra features does this tool have versus others?

(1) 11 stage types with per-stage JSON spec editor. (2) Stage enable/disable toggle for debugging. (3) Reorder stages up/down. (4) 8 accumulators + 20 expressions evaluated in-browser. (5) Per-stage live preview on pasted sample docs (intermediate output shown). (6) 6 driver code exports. (7) Stage validation per type (object / integer / string / path). (8) Pipeline-level validation with stageId pinpointing errors. (9) Field-path autocomplete extracted from sample docs. (10) Dot-notation field access (including array-of-objects). (11) $facet sub-pipeline execution. (12) $unwind preserveNullAndEmptyArrays option. (13) localStorage history (max 20). (14) Shareable URL with full pipeline state. (15) Load sample documents button.

Search tools and actions

Search across all 616 tools, categories, and quick actions.