SQL to MongoDB Converter

Convert basic SQL SELECT queries into MongoDB find() calls — filters, sorting and limits.

100% FreeNo sign-upPrivate — runs in your browser

Covers basic SELECT → find only: WHERE with AND, ORDER BY and LIMIT. It is not a full SQL translator — see limitations.

Copied to clipboard

How to use this tool

1
Paste a SELECT query

A simple SELECT … FROM … query, optionally with WHERE, ORDER BY and LIMIT.

2
Convert

The MongoDB find() call appears in the output box, with the filter shown below it.

3
Check the mapping

Confirm each WHERE condition became the filter operator you expect.

4
Copy or download it

Copy the code or download it as a .js snippet for your app.

Formula & worked example

SELECT fields become a projection (1 per field, or no projection for *), FROM gives the collection, WHERE conditions become a filter (= value, != $ne, > $gt, < $lt, >= $gte, <= $lte, IN $in), ORDER BY becomes .sort() (1 ascending, -1 descending) and LIMIT becomes .limit().

SELECT name, age FROM users WHERE age > 18 AND city = 'London' ORDER BY age DESC LIMIT 10 becomes db.users.find({"age": {"$gt": 18}, "city": "London"}, {"name": 1, "age": 1}).sort({"age": -1}).limit(10);

Limitations — read this before you rely on it

Limited scope, stated honestly: only single-table SELECT with WHERE conditions joined by AND, one ORDER BY field and LIMIT. NOT supported: JOINs, GROUP BY / aggregates, subqueries, OR, LIKE, DISTINCT, UPDATE/INSERT/DELETE and schema or type mapping — MongoDB documents have no fixed schema to map columns onto.

Frequently asked questions

No. Only single-table SELECT queries are supported. JOINs, GROUP BY, subqueries and OR are rejected with a plain message, not silently misconverted.

It is not supported. LIKE has no single equivalent operator here — use a $regex in MongoDB by hand for pattern matching.

It produces find(filter) with no projection, so all document fields are returned.

Numbers, quoted strings, true/false and null are parsed. Dates and ObjectIds have no SQL equivalent in this tool, so pass them as strings and convert by hand.

It is a read-only find() snippet, but always review it against your real collection and field names before running it on production data.