Paste any SQL query and get the MongoDB equivalent instantly. Supports SELECT, INSERT, UPDATE, DELETE, GROUP BY, HAVING, LIKE, IN, IS NULL and more.
This tool helps you translate your standard SQL (Structured Query Language) queries into the equivalent query syntax used by MongoDB, a popular NoSQL document database. It is designed for developers transitioning or working with both relational databases and MongoDB.
Enter your SQL query in the input box, and the corresponding MongoDB query will be generated below. Thanks to an advanced SQL parser, this tool can now handle more complex queries including basic aggregations and varied WHERE clauses.
Supported SQL Operations (Enhanced)Translates column selection and WHERE conditions into a MongoDB find() call with query filter and projection.
ORDER BY becomes sort(), LIMIT becomes limit(), OFFSET becomes skip().
GROUP BY with aggregate functions (COUNT, SUM, AVG, MIN, MAX) is translated into a MongoDB aggregation pipeline.
HAVING filters are translated into a second $match stage in the aggregation pipeline, applied after grouping.
SQL LIKE patterns with % (any characters) and _ (single character) are converted to MongoDB regular expressions.
Full support for IN/$in, NOT IN/$nin, IS NULL/{$eq:null}, IS NOT NULL/{$ne:null}, AND/$and, OR/$or.
Single-row INSERT becomes insertOne(). Multi-row INSERT becomes insertMany(). Column names become document field names.
SQL SET clauses become MongoDB $set operators. The WHERE condition becomes the filter document.
DELETE FROM with a WHERE condition becomes deleteMany(). Use with care — no WHERE deletes all documents.
| SQL Operator | MongoDB Operator | Notes |
|---|---|---|
| = | $eq (or implicit) | Exact match |
| != / <> | $ne | Not equal |
| > | $gt | Greater than |
| >= | $gte | Greater than or equal |
| < | $lt | Less than |
| <= | $lte | Less than or equal |
| IN (...) | $in | Value in list |
| NOT IN (...) | $nin | Value not in list |
| LIKE '%x%' | $regex: /.*x.*/ | % → .*, _ → . |
| NOT LIKE | $not: /pattern/ | Negated regex |
| IS NULL | field: null | Includes missing fields |
| IS NOT NULL | $ne: null | Field exists and is not null |
| AND | $and | All conditions must match |
| OR | $or | Any condition must match |
| COUNT(*) | $sum: 1 | In $group stage |
| SUM(f) | $sum: "$f" | In $group stage |
| AVG(f) | $avg: "$f" | In $group stage |
| MIN(f) | $min: "$f" | In $group stage |
| MAX(f) | $max: "$f" | In $group stage |
| ORDER BY ASC | sort({ f: 1 }) | Ascending |
| ORDER BY DESC | sort({ f: -1 }) | Descending |
| LIMIT n | limit(n) | |
| OFFSET n | skip(n) |
Moving from MySQL, PostgreSQL or SQLite to MongoDB? This tool helps you translate your existing query logic quickly and accurately, reducing the risk of errors during migration.
If you know SQL, this converter shows you exactly how each SQL concept maps to MongoDB's document model — making it the fastest way to learn MongoDB query syntax.
Even experienced MongoDB developers sometimes think in SQL first. Use this tool as a quick reference to translate your mental model into the correct MongoDB syntax.
Share converted queries with teammates who come from a SQL background. A common language reduces friction when working across different database ecosystems.