SQL to NoSQL
Paste a single SQL SELECT statement and the converter rewrites it as an equivalent MongoDB find() query. It maps the selected columns to a projection, the WHERE clause to a filter, ORDER BY to .sort() and LIMIT to .limit(). It is a query rewriter for simple statements, not a migration tool: JOIN, GROUP BY, aggregations and subqueries are not supported.
How the conversion works
-
1
Parse the SELECT
The tool reads a single statement of the form `SELECT columns FROM table [WHERE ...] [ORDER BY ...] [LIMIT n]`.
-
2
Map each clause
Columns become a projection `{ col: 1 }`, `WHERE` becomes a filter, `ORDER BY` becomes `.sort()` and `LIMIT` becomes `.limit()`.
-
3
Translate the operators
Comparison operators map to Mongo operators: `>` to `$gt`, `<` to `$lt`, `>=` to `$gte`, `<=` to `$lte`, `!=` to `$ne`, and `=` to a direct match.
-
4
Copy the output
The generated `db.collection.find(...)` line is ready to paste into the mongosh shell or a driver call.
A worked example
SQL:
SELECT name, price FROM products WHERE price > 100 ORDER BY price DESC LIMIT 5;
MongoDB query:
db.products.find({ price: { $gt: 100 } }, { name: 1, price: 1 }).sort({ price: -1 }).limit(5)
What the converter maps
| SQL | MongoDB find() |
|---|---|
SELECT a, b |
projection { a: 1, b: 1 } |
SELECT * |
all fields (empty projection) |
FROM users |
db.users.find(...) |
WHERE a = 5 |
{ a: 5 } |
WHERE a > 5 |
{ a: { $gt: 5 } } |
WHERE a >= 5 |
{ a: { $gte: 5 } } |
WHERE a != 5 |
{ a: { $ne: 5 } } |
WHERE a AND b |
{ a: ..., b: ... } |
WHERE a OR b |
{ $or: [ ... ] } |
ORDER BY a DESC |
.sort({ a: -1 }) |
LIMIT 10 |
.limit(10) |
What is not supported
- JOINs. Only a single table is read. Combining collections needs
$lookupor a denormalized data model, which is a schema decision, not a query rewrite. - GROUP BY and aggregations.
COUNT,SUM,AVGandGROUP BYrequire the aggregation pipeline (db.collection.aggregate([...])), which this tool does not generate. - Subqueries, CTEs and window functions. Rethink the model or split the work into stages; they cannot be expressed in a
find(). - IN, LIKE and BETWEEN. The
WHEREparser handles the comparison operators=,>,<,>=,<=,!=and<>only. - Mixed AND and OR. A
WHEREclause is treated as all-ANDor all-OR; do not combine both in one statement. - INSERT, UPDATE, DELETE, CREATE TABLE. Only
SELECTis converted.
About the output
The result is always a single db.collection.find(filter, projection) line, optionally followed by .sort() and .limit(). It targets the MongoDB shell and drivers. It does not produce Firestore or Elasticsearch queries, and it does not choose indexes or optimize for performance. Test the query against your own data before relying on it.
Frequently Asked Questions
No. The output is always a MongoDB find() query for the mongosh shell or a driver. There is no target selector for other document stores.
No. Those need the MongoDB aggregation pipeline (aggregate([...])), which this tool does not generate. It only produces find() queries with a filter, projection, sort and limit.
No. Only a single FROM table is read. NoSQL stores favor embedding or referencing, so a join usually means a data-model change rather than a query rewrite.
No. Only SELECT statements are converted. Collections in MongoDB are schemaless by default, so there is no table definition to translate.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
Color Wheel Explorer
Explore the colour wheel interactively. Rotate harmonies, compare HSL vs RYB, spot complementary and triadic pairs in real time.
Tool available in other languages
- SQL till NoSQL [SV]
- Từ SQL sang NoSQL [VI]
- SQL zu NoSQL [DE]
- Dari SQL ke NoSQL [ID]
- SQL から NoSQL へ [JA]
- SQL na NoSQL [PL]
- من SQL إلى NoSQL [AR]
- SQL para NoSQL [PT]
- SQL a NoSQL [ES]
- SQL vers NoSQL [FR]
- SQL → NoSQL [KO]
- SQL naar NoSQL [NL]
- การแปลง SQL เป็น NoSQL [TH]
- SQL a NoSQL [IT]
- SQL в NoSQL [RU]
- SQL'den NoSQL'e [TR]
- 从 SQL 到 NoSQL [ZH]