Canonical: https://toolipedia.app/sql-to-mongodb-and-mongodb-to-sql-query-translator

# SQL to MongoDB and MongoDB to SQL Query Translator

Translate simple SQL SELECT queries with WHERE, GROUP BY, ORDER BY and LIMIT into MongoDB find or aggregate calls, and translate simple find and aggregate calls back to SQL.

Breadcrumbs: Toolipedia > Developer tools > Code and developer utilities > SQL to MongoDB and MongoDB to SQL Query Translator

## About SQL to MongoDB and MongoDB to SQL Query Translator

Moving between SQL and MongoDB means rewriting every query. This translator handles the common single-table shapes. SQL to MongoDB: SELECT columns FROM one table with WHERE (AND, OR, NOT, IN, BETWEEN, LIKE, IS NULL), GROUP BY with COUNT, SUM, AVG, MIN and MAX, HAVING, ORDER BY, LIMIT and OFFSET become find or aggregate calls. MongoDB to SQL: find, findOne, countDocuments, distinct and aggregate with $match, $group, $sort, $limit and $project become SELECT statements. Joins and subqueries are reported as not supported.

## How to use SQL to MongoDB and MongoDB to SQL Query Translator
1. Choose the direction: SQL to MongoDB or MongoDB to SQL.
2. Paste the query. For MongoDB write it as in mongosh, for example db.users.find({ age: { $gte: 18 } }).
3. Copy the result and check it against a few real documents or rows, because collation and case rules differ between the two systems.

## Why use this tool?
- Private: everything happens in your browser. Nothing you enter is uploaded.
- Free, with no sign-up, no watermark and no limit on how often you use it.
- Works on phones, tablets and computers: Android, iPhone, Windows, Mac and Linux. Nothing to install.

## Also known as
- sql to mongodb and mongodb to sql query translator
- sql to mongodb query
- mongodb to sql
- mongodb aggregate to sql
- convert sql select to mongo find

## Frequently asked questions

### Why does the Mongo result hide the _id field?

A SQL result only has the columns you list, while MongoDB returns _id unless you exclude it. The translation adds _id: 0 so the output has the same shape; remove it if you want the id.

### Which operators are not supported?

Joins, subqueries, window functions, expressions in the select list and operators such as $elemMatch or $expr are not translated. The tool says which part it cannot convert instead of guessing.

### How is LIKE translated?

A pattern such as 'An%' becomes the regular expression ^An, and a % at both ends becomes an unanchored match. In the other direction only simple regular expressions that use ., .*, ^ and $ can become LIKE.

### Is SQL to MongoDB and MongoDB to SQL Query Translator free?

Yes. SQL to MongoDB and MongoDB to SQL Query Translator on Toolipedia is free to use, with no sign-up and no watermark.

### Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

### Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

### Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

## Related tools

More free tools that go well with SQL to MongoDB and MongoDB to SQL Query Translator:
- [SQL Query Builder](https://toolipedia.app/sql-query-builder)
- [Database Cheat Sheets](https://toolipedia.app/database-cheat-sheets)
- [SQL formatter](https://toolipedia.app/sql-formatter)
- [SQL minifier](https://toolipedia.app/sql-minifier)
- [SQL Table and Column Name Extractor](https://toolipedia.app/sql-table-and-column-name-extractor)
