SQL to MongoDB converter
Paste a WHERE clause, or a whole SELECT, and get the MongoDB filter document that matches the same rows.
- free
- no sign-up
- runs in your browser
- MIT
How it converts
The WHERE clause is parsed into qnot's query tree, then written out with the mongo codec. Comparisons map to $eq, $ne, $lt, $gte; IN and NOT IN to $in and $nin; BETWEEN to a $gte/$lte pair; IS NULL to null.
LIKE patterns become anchored, escaped regular expressions: a leading and trailing % is contains, a trailing % starts-with, a leading % ends-with. Patterns with _ or an inner % are refused rather than guessed.
Dates stay ISO strings. If your collection stores BSON dates, wrap them with new Date() in your app, or declare the field as f.date() and convert in one place.
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 SQL does it understand?
- WHERE conditions: comparisons, IN, BETWEEN, LIKE/ILIKE, IS [NOT] NULL, AND, OR, NOT and parentheses, with quoted identifiers and string, number and boolean literals. Joins, subqueries and placeholders like $1 are not part of a filter and are refused with an error.
- Why does it show a schema?
- qnot's codecs are typed by a schema. The tool infers a permissive one from your input (numbers, booleans, dates, lists, nested arrays), so you can paste any query. In your app you declare the fields once with defineFields and get the same conversion with exact types.
More converters
Every format qnot speaks- MongoDB → SQLMongoDB to SQL 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