{
  "slug": "mongodb-query-to-sql",
  "name": "gizza-ai/mongodb-query-to-sql",
  "version": "0.1.0",
  "title": "MongoDB Query to SQL Converter — WHERE Clause or SELECT — gizza.ai",
  "description": "Paste a MongoDB find filter or db.collection.find() shell call and get the equivalent SQL condition, WHERE clause, or full SELECT statement.",
  "tags": [
    "mongodb to sql",
    "mongodb query converter",
    "mongo find to select",
    "mongodb where clause",
    "nosql to sql",
    "mongodb migration",
    "mongo filter translator",
    "db.collection.find to sql"
  ],
  "category": "network",
  "urls": {
    "page": "https://gizza.ai/tools/mongodb-query-to-sql/",
    "markdown": "https://gizza.ai/tools/mongodb-query-to-sql/index.md",
    "descriptor": "https://gizza.ai/tools/mongodb-query-to-sql/tool.json",
    "deep_link_example": "https://gizza.ai/tools/mongodb-query-to-sql/?query=db.users.find%28%7B%20age%3A%20%7B%20%24gte%3A%2021%20%7D%2C%20status%3A%20%22active%22%20%7D%29&output=where&dialect=ansi&table=sales.orders&nested=column&quote_identifiers=true&rename_id=true"
  },
  "cli": "gizza tool mongodb-query-to-sql 'db.users.find({ age: { $gte: 21 }, status: \"active\" })'",
  "tool": {
    "description": "Translate a MongoDB query into SQL. Accepts a bare filter document or a full db.<collection>.find(...).sort(...).limit(...).skip(...) shell call in relaxed syntax, and emits a bare boolean condition, a WHERE clause, or a complete SELECT statement. Supports $eq $ne $gt $gte $lt $lte $in $nin $and $or $nor $not $exists $regex $mod $size, projections, sort/limit/skip/count, Extended JSON and shell helpers (ObjectId, ISODate, /re/i), and dotted paths as either column names or JSON extractions. Options: output where|condition|select, dialect ansi|postgres|mysql|sqlserver, table (for select output), nested column|json, quote_identifiers (default true), rename_id (default false). Aggregation pipelines and writes are rejected with an explanation. Max 100,000 characters.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "dialect": {
          "default": "ansi",
          "description": "SQL dialect for identifier quoting, regex, JSON extraction, and paging: 'ansi' (default, \"double quotes\"), 'postgres' (~*, ->>, jsonb_array_length), 'mysql' (`backticks`, REGEXP_LIKE, JSON_EXTRACT), or 'sqlserver' ([brackets], TOP (n), OFFSET ... ROWS FETCH NEXT ... ROWS ONLY).",
          "enum": [
            "ansi",
            "postgres",
            "mysql",
            "sqlserver"
          ],
          "type": "string"
        },
        "nested": {
          "default": "column",
          "description": "How dotted paths like 'address.city' are translated: 'column' (default) treats the whole path as one column name; 'json' emits a JSON extraction for the chosen dialect (->>/JSON_UNQUOTE(JSON_EXTRACT(..))/JSON_VALUE(..)), with Postgres casts so numeric and boolean comparisons stay type-correct.",
          "enum": [
            "column",
            "json"
          ],
          "type": "string"
        },
        "output": {
          "default": "where",
          "description": "What SQL to emit: 'where' (default) is the condition prefixed with WHERE; 'condition' is the bare boolean expression for pasting into a larger statement; 'select' is a full SELECT ... FROM ... WHERE ... ORDER BY ... statement built from the projection, sort, limit, and skip in the query.",
          "enum": [
            "where",
            "condition",
            "select"
          ],
          "type": "string"
        },
        "query": {
          "description": "The MongoDB query to translate. Either a bare filter document ({ age: { $gte: 21 } }) or a full shell call (db.users.find({...}, {...}).sort({...}).limit(10).skip(20)), including findOne, count, and countDocuments. Relaxed shell syntax is accepted: unquoted keys, single quotes, trailing commas, // and /* */ comments, /regex/i literals, ObjectId()/ISODate()/new Date()/NumberLong() helpers, and MongoDB Extended JSON. Max 100,000 characters.",
          "type": "string"
        },
        "quote_identifiers": {
          "default": true,
          "description": "Wrap column and table names in the dialect's quoting characters (default true). Turn it off for bare identifiers like age >= 21 when your schema needs no quoting.",
          "type": "boolean"
        },
        "rename_id": {
          "default": false,
          "description": "Rewrite MongoDB's _id field as id in the generated SQL (default false). Useful when the relational schema renamed the primary key during migration.",
          "type": "boolean"
        },
        "table": {
          "default": "",
          "description": "Table name used by the 'select' output, e.g. orders or sales.orders (dotted names are quoted per part). Leave empty (default) to use the collection from the pasted db.<collection>.find(...) call; a bare filter document with 'select' output needs this filled in.",
          "type": "string"
        }
      },
      "required": [
        "query"
      ],
      "type": "object"
    }
  }
}