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 translates standard SQL queries into the equivalent syntax used by MongoDB, a document-oriented NoSQL database. It is built for developers who are migrating away from a relational database, or who work with both worlds at the same time.
Type your SQL query in the input panel and the matching MongoDB query appears alongside it. A real SQL parser handles the query, so complex WHERE clauses and basic aggregations are converted correctly rather than guessed at.
Supported SQL operationsColumn selection and WHERE conditions become a MongoDB find() call with a query filter and a projection.
ORDER BY becomes sort(), LIMIT becomes limit(), and OFFSET becomes skip().
GROUP BY combined with aggregate functions (COUNT, SUM, AVG, MIN, MAX) is translated into a MongoDB aggregation pipeline.
A HAVING filter becomes a second $match stage in the pipeline, applied after the grouping has happened.
SQL LIKE patterns using % (any characters) and _ (a single character) are converted into MongoDB regular expressions.
Full support for IN/$in, NOT IN/$nin, IS NULL, IS NOT NULL/$ne, AND/$and and OR/$or, including parentheses for grouping.
A single-row INSERT becomes insertOne(); a multi-row INSERT becomes insertMany(). Column names become document field names.
The SET clause becomes a MongoDB $set operator and the WHERE condition becomes the filter document.
DELETE FROM with a WHERE condition becomes deleteMany(). Handle with care: without a WHERE clause, every document is removed.
| 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.*/ | % becomes .*, _ becomes . |
| NOT LIKE | $not: /pattern/ | Negated regular expression |
| IS NULL | field: null | Also matches missing fields |
| IS NOT NULL | $ne: null | Field exists and is not null |
| AND | $and | All conditions must match |
| OR | $or | Any condition may match |
| COUNT(*) | $sum: 1 | Inside the $group stage |
| SUM(f) | $sum: "$f" | Inside the $group stage |
| AVG(f) | $avg: "$f" | Inside the $group stage |
| MIN(f) | $min: "$f" | Inside the $group stage |
| MAX(f) | $max: "$f" | Inside the $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, SQL Server or SQLite to MongoDB? Translate your existing query logic quickly and reduce the risk of mistakes during the migration.
If you already know SQL, seeing each concept mapped side by side is the fastest route to the MongoDB query language and the document model behind it.
Even experienced MongoDB developers often think in SQL first. Use the converter as a quick reference to turn that mental model into correct syntax.
Share converted queries with colleagues coming from a relational background. A shared reference removes friction between two different database cultures.
Paste your SQL statement into the input panel and press Convert. The tool parses the SQL and returns the equivalent MongoDB shell command: SELECT becomes find(), WHERE conditions become a query filter, ORDER BY becomes sort(), and LIMIT and OFFSET become limit() and skip(). No registration or installation is required.
MongoDB has no LIKE keyword; pattern matching is done with $regex. A SQL % wildcard becomes .* and a SQL _ wildcard becomes a single dot. So WHERE name LIKE '%mongo%' converts to { name: { $regex: /.*mongo.*/ } }, and NOT LIKE is wrapped in $not.
GROUP BY maps to an aggregation pipeline with a $group stage. The grouped columns become the _id of that stage and the aggregate functions become accumulators: COUNT(*) becomes { $sum: 1 }, SUM(field) becomes { $sum: "$field" }, and AVG, MIN and MAX map to $avg, $min and $max. A HAVING clause becomes a second $match stage placed after $group.
Not automatically. A JOIN in MongoDB requires a $lookup stage plus a decision about whether the related data should be embedded or referenced, and that depends on your schema design rather than on the SQL alone. Convert single-table queries here and add the $lookup stage yourself.
No. This converter translates query syntax, not data. To move the rows themselves you need a migration tool such as MongoDB Relational Migrator, which is free and supports Oracle, SQL Server, MySQL and PostgreSQL. Use this converter alongside it to translate the queries already embedded in your application code.
Yes. The tool is completely free, runs in your browser, requires no account and stores none of your queries. It is available in English, Italian, Russian, Chinese, French and Spanish.
Converting queries is the last step. These guides cover the part that decides whether a migration succeeds: how to reshape a relational schema into documents.