MongoDB to SQL converter
Paste a find() filter, shell syntax welcome, and get the WHERE clause for your database, inline or parameterized.
- free
- no sign-up
- runs in your browser
- MIT
How it converts
The filter is read with the mongo codec: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $regex (anchored or contains), $and, $or, $nor, $not and $elemMatch. Shell syntax is accepted: unquoted keys, single quotes, regex literals and ISODate().
Choose the SQL dialect and how values are written. Inline values are escaped per dialect so they mean the same under every server setting; numbered, positional or named placeholders return the values separately for your driver to bind.
$elemMatch becomes an array group. SQL can only express it on Postgres (as EXISTS over jsonb_array_elements); other dialects say so instead of dropping the condition.
Use it in your app
follows your input and settingsThe converter is qnot's codecs. Declare the fields once and the same two calls run on your server or in the browser, typed end to end.
Questions
- Is my query sent anywhere?
- No. The converter is qnot running in your browser: parsing, schema inference and conversion all happen on this page, and nothing you paste leaves your browser.
- Which MongoDB operators are supported?
- Comparison operators, $in/$nin, $regex, $and/$or/$nor/$not, $all and $elemMatch, plus $expr forms that qnot itself writes. Operators with no SQL equivalent in a filter, such as $exists, $where or $text, are reported as errors.
- Is the generated SQL safe to run?
- Values are escaped for the chosen dialect, and LIKE patterns match literally. For queries built from user input, pick a placeholder style and pass the values to your driver as bound parameters.
More converters
Every format qnot speaks- SQL → MongoDBSQL to MongoDB converter
- SQL → JsonLogicSQL to JsonLogic converter
- JsonLogic → SQLJsonLogic to SQL converter
- JsonLogic → MongoDBJsonLogic to MongoDB converter
- SQL → ElasticsearchSQL to Elasticsearch converter
- react-querybuilder → SQL · MongoDB · JsonLogicreact-querybuilder to SQL converter
- RAQB → SQL · MongoDB · JsonLogicRAQB tree to SQL converter