This SQL → MongoDB Query Converter helps you migrate or test SQL SELECT logic in MongoDB by automatically translating:
$eq
, $gt
, $lte
, etc.)$and
/$or
arrays)IN (…) → $in
)BETWEEN … AND … → $gte/$lte
)$regex
)SQL (before):
SELECT name, age FROM users WHERE age >= 18 AND status = 'active';
MongoDB (after):
db.users.find(
{ "age": { "$gte": 18 }, "status": "active" },
{ "name": 1, "age": 1 }
);
SQL (before):
SELECT * FROM orders WHERE status = 'shipped' OR total > 100;
MongoDB (after):
db.orders.find(
{ "$or": [ { "status": "shipped" }, { "total": { "$gt": 100 } } ] }
);
SQL (before – IN):
SELECT * FROM products WHERE category IN ('A','B','C');
MongoDB (after – $in):
db.products.find(
{ "category": { "$in": ["A","B","C"] } }
);
SQL (before – BETWEEN):
SELECT * FROM sales WHERE price BETWEEN 10 AND 50;
MongoDB (after – $gte/$lte):
db.sales.find(
{ "price": { "$gte": 10, "$lte": 50 } }
);
SQL (before – LIKE):
SELECT * FROM users WHERE name LIKE 'Jo%';
MongoDB (after – $regex):
db.users.find(
{ "name": { "$regex": "^Jo.*$" } }
);
SQL (before – ORDER BY):
SELECT * FROM logs ORDER BY timestamp DESC;
MongoDB (after – .sort):
db.logs.find().sort({ "timestamp": -1 });
SQL (before – LIMIT/OFFSET):
SELECT * FROM logs LIMIT 10 OFFSET 20;
MongoDB (after – .limit/.skip):
db.logs.find()
.skip(20)
.limit(10);
Choose how your JSON is pretty‑printed:
Compact (indent = 0): { "age": { "$gte": 18 }, "status": "active" }
Pretty (indent = 4):
{
"age": {
"$gte": 18
},
"status": "active"
}