consolelog.tools

MongoDB Query Builder

Build MongoDB queries visually and watch them render live. Switch between Find mode (field/operator/value conditions, projection, sort, limit, skip) and an Aggregate pipeline builder ($match, $group, $sort, $project, $limit, $skip, $unwind, $lookup). The exact same query is emitted for four targets at once - the Mongo shell, the Node.js driver, Mongoose, and Python's pymongo - so you can copy whichever your stack uses. Everything runs in your browser; no database is contacted.

About this ToolHow it works, benefits & use cases

Build MongoDB queries visually from structured inputs and watch them render live, then copy the exact same query for whichever driver your stack uses. Two modes cover the bulk of day-to-day querying. Find mode lets you stack filter conditions as field + operator + value rows - $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $regex, and $exists - and add a projection (comma-separated fields), a sort (field:1 or field:-1), a limit, and a skip; the builder composes a chained db.collection.find({...}).sort({...}).skip(n).limit(n) call. Aggregate mode is a full pipeline builder where you add and reorder stages - $match, $group (with $sum, $avg, $min, $max, and $count accumulators), $sort, $project, $limit, $skip, $unwind, and $lookup - to assemble a pipeline array. Whatever you build is emitted simultaneously for four targets: the Mongo shell, the Node.js driver, Mongoose, and Python pymongo, so the right syntax is one dropdown away. Values are coerced for you - 42 becomes a number, true/false booleans, null a null, and $in/$nin take a comma-separated list. Start from a template, then copy, download, or share the result via URL. Everything runs in your browser and no database is ever contacted.

How to Use

  1. 1Enter the collection name and choose a mode - Find or Aggregate.
  2. 2In Find mode, add filter conditions (field, operator, value), then optionally set projection fields, a sort, a limit, and a skip.
  3. 3In Aggregate mode, add pipeline stages such as $match, $group, $sort, $project, $limit, $skip, $unwind, or $lookup and fill in each stage.
  4. 4Pick an output target - Mongo shell, Node.js driver, Mongoose, or pymongo - to render the same query in that syntax.
  5. 5Copy the query, download it, or share the URL; load a template for a ready-made starting point.

Key Benefits

  • Two modes: a Find builder and a full Aggregate pipeline builder
  • Ten filter operators including $in, $nin, $regex, and $exists
  • Aggregate stages: $match, $group, $sort, $project, $limit, $skip, $unwind, $lookup
  • Group accumulators: $sum, $avg, $min, $max, and $count
  • The same query emitted for the Mongo shell, Node.js driver, Mongoose, and pymongo
  • Automatic value coercion for numbers, booleans, null, and comma-separated arrays
  • Live output, ready-made templates, and a fully shareable URL
  • Runs entirely in your browser - no database connection

Common Use Cases

  • Drafting a find() with a filter, projection, sort, and paging without syntax slips
  • Assembling an aggregation pipeline with a $match, $group, and $sort from scratch
  • Translating a query you wrote in the shell into Node.js, Mongoose, or pymongo syntax
  • Looking up the correct shape for $in array queries, $regex, or $lookup joins
  • Sharing a reproducible query with a teammate as a single link

The same query rendered for your chosen driver

db.users.find({
  status: "active"
})
Templates:

Collection

Filter conditions

Projection & ordering

Comma-separated field names to include

field:1 (asc) or field:-1 (desc), comma-separated

Limit
Skip

A limit or skip of 0 is omitted from the query.

One query, four drivers

The structured inputs are rendered to the same query for the Mongo shell, the Node.js driver, Mongoose, and pymongo. Switch the output target and copy whichever your stack uses.

Smart value coercion

Values are coerced automatically: 42 becomes a number, true/false booleans, null a null, and $in/$nin accept a comma-separated list.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools