JSON to SQL
Convert a JSON filter to a WHERE clause, or a JSON object to an INSERT statement.
Parameterized output is the default; generated SQL is never executed.
About This Tool
Converts a JSON filter object with Mongo-style operators into a SQL WHERE clause, or a flat
JSON object into an INSERT statement, across PostgreSQL, MySQL, and SQLite quoting
conventions. The swap button reverses this, parsing an existing WHERE, INSERT,
or UPDATE statement back into JSON.
Output is generated text only and is never executed against a database. If the goal is a CSV export or a URL query string instead of SQL, see JSON to CSV or JSON to Query String.
Key Features
- Two conversion kinds: filter-to-
WHEREor object-to-INSERT, picked from the Conversion dropdown. - Three SQL dialects: PostgreSQL, MySQL, and SQLite, each with correct identifier quoting and placeholder syntax.
- Named or positional placeholders: switch between
:nameand?/$nstyles. - One-click JSON formatting: the Format button pretty-prints the input before converting.
- Reverse parsing: the ⇌ swap button turns existing SQL back into JSON.
Example
A filter with a comparison and an IN clause:
{
"status": "active",
"age": { "$gt": 18 },
"role": { "$in": ["admin", "editor"] }
} produces (PostgreSQL, parameterized):
WHERE "status" = :status AND "age" > :age AND "role" IN (:role_0, :role_1)
FAQ
- Can I convert SQL back to JSON?
- Yes! Click the ⇌ swap button or toggle the Direction dropdown to parse SQL statements (INSERT INTO, UPDATE SET, WHERE) back into JSON.
- Which operators are supported?
$eq $ne $gt $gte $lt $lte $in $nin $like $isNull $and $or, including nested$and/$or.- Is the generated SQL safe to run?
- Parameterized output never inlines values, so it is safe against SQL injection. Literal mode inlines escaped values directly and should only be used after review.
- Does this connect to a database?
- No. SQL is generated as text only. It is never executed and no connection is ever opened.