SQL → MongoDB Converter The ultimate, heavyweight VS Code extension for converting SQL queries into MongoDB operations. One-way. Blazing fast. 🏆 Why sql2mongodb? Most SQL-to-Mongo converters are basic web wrappers, rely on fragile Regex, and fail the moment you throw a LEFT JOIN or CASE WHEN at them. sql2mongodb is built differently. It runs natively in VS Code, uses a custom-built Recursive Descent AST Parser, and handles the complex stuff that others can't. Features that smash the competition: 🧠 True AST Parsing: No regex shortcuts. We tokenize and parse your SQL into a proper Abstract Syntax Tree for 100% accurate conversion. 🖥️ Live Webview UI: A beautiful, built-in side panel that updates as you convert. No browser tabs needed. 🎨 3 Output Formats: Switch seamlessly between Mongo Shell, Node.js Driver, and Mongoose syntax with one click. 📖 Explain Mode: Toggle a step-by-step breakdown of how your SQL mapped to Mongo (perfect for learning). ✍️ Inline Replace: Hit a shortcut and your SQL is instantly overwritten with the Mongo equivalent. 📋 Copy to Clipboard: Grab the code without touching your editor. 🛡️ Smart Error Recovery: If line 5 has a syntax error, we still convert lines 1-4 and 6+ perfectly. 📦 DDL Support: Converts CREATE TABLE into Mongoose Schemas or MongoDB $jsonSchema validators. ⚡ Supported SQL Syntax We don't just do basic SELECT *. We handle the edge cases: Queries: SELECT, INSERT, UPDATE, DELETE Filtering: WHERE, AND, OR, IN, NOT IN, BETWEEN, LIKE, IS NULL Joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN (Mapped to $lookup) Aggregation: GROUP BY, HAVING, COUNT, SUM, AVG, MIN, MAX (Mapped to $group) Sorting: ORDER BY (ASC/DESC), LIMIT, OFFSET Advanced: UNION, UNION ALL, CASE WHEN (Mapped to $switch), Subqueries, EXISTS Schema: CREATE TABLE, CREATE INDEX, DROP TABLE, TRUNCATE ⌨️ Keybindings & Commands Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) or right-click in your editor: Command Windows / Linux macOS Action SQL→Mongo: Convert Selection Ctrl+Shift+M Cmd+Shift+M Opens panel & converts SQL→Mongo: Inline Replace Ctrl+Alt+M Cmd+Alt+M Replaces SQL in editor SQL→Mongo: Copy to Clipboard Ctrl+Shift+Alt+M Cmd+Shift+Alt+M Copies Mongo to clipboard SQL→Mongo: Open Preview Panel - - Opens empty panel 🛠️ How to Use Write or paste any SQL query in your editor. Highlight the SQL text. Press Ctrl+Shift+M. The SQL → MongoDB panel opens on the right. Use the Shell / Node.js / Mongoose buttons to change the output dialect. Click Explain to see the mapping logic. Click Copy to grab the code or Insert to paste it into your file. 📸 Example *SQL Input: SELECT name, age FROM users WHERE status = 'active' AND age > 18 ORDER BY name ASC LIMIT 10; MongoDB *Output (Shell): db.users.find({ status: 'active', age: { $gt: 18 } }, { name: 1, age: 1, _id: 0 }).sort({ name: 1 }).limit(10) |