DevTools Logo

MongoDB Query Builder

MongoDB Query Builder

Build find filters or aggregate pipelines from visual rows — field, operator, value

Query Builder

MATCH

Matches values equal to the specified value. Shorthand: { field: value }.

    Examples

    Age range with AND

    Input
    age $gte 18 AND age $lt 65
    Output
    { "$and": [ { "age": { "$gte": 18 } }, { "age": { "$lt": 65 } } ] }

    Two numeric comparisons combined with AND logic.

    Count by department

    Input
    status = active, group by department, sort count DESC, limit 10
    Output
    Pipeline: $match → $group → $sort → $limit

    Aggregate mode groups matched documents and ranks departments by count.

    About this tool

    MongoDB queries are JSON — find filters, projection documents, and aggregate pipeline stages. Writing them by hand means remembering operator names ($gte, $in, $regex), BSON types, and how AND/OR logic nests in $and and $or arrays.

    This builder turns visual filter rows (field, operator, value) into copy-ready find JSON or an aggregate pipeline. Choose find mode for filter/projection/sort/limit, or aggregate mode for $match, optional $group by field, $sort, and $limit. Toggle shell output for db.collection.find() syntax. Everything runs in your browser — no database connection.

    How to use

    1. Set collection

      Enter the collection name used in shell output (e.g. users).

    2. Add filters

      Click Add filter, set field, operator, and value. Combine rows with AND or OR.

    3. Pick output mode

      Find emits a filter document; Aggregate builds a pipeline with $match and optional $group.

    4. Copy output

      Copy JSON or toggle Shell for mongo shell syntax.

    Use cases

    Draft find queries

    Prototype filters before pasting into Compass, Studio 3T, or application code.

    Learn operators

    Each operator shows inline help text explaining $in, $regex, $exists, and more.

    Aggregate reports

    Build $match + $group pipelines for simple analytics without writing JSON by hand.

    Common mistakes

    Mistake:Using string type for numeric comparisons.

    Fix:Set value type to number for $gt, $gte, $lt, and $lte so BSON types match your schema.

    Mistake:Forgetting $group in aggregate mode.

    Fix:Add a group-by field or the pipeline only filters — no aggregation stage is emitted without it.

    Frequently asked questions

    References & standards