DevTools Logo

JSON to SQL Converter

JSON to SQL Converter

Turn JSON records into parameterised INSERT, UPDATE or UPSERT statements with bindings.

Runs in your browser
Try an example

JSON records

SQL & bindings

Paste JSON to generate SQL

Values are emitted as bindings, never interpolated into the statement text.

Paste an array of JSON objects and get dialect-correct SQL statements with values supplied as bindings instead of interpolated text. Choose INSERT, UPDATE or UPSERT, a table name, key column and an optional column subset.

PostgreSQL INSERT

JSON: [{"id":1,"name":"Alice"}]
SQL: INSERT INTO "users" ("id", "name") VALUES ($1, $2);
Bindings: [[1, "Alice"]]

Each statement has its own numbered placeholders and binding array.

MySQL UPSERT

SQL: INSERT INTO `users` (`id`, `name`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `name` = ?;
Bindings: [[1, "Alice", "Alice"]]

Identifiers and conflict clauses follow the selected dialect.

Examples

PostgreSQL INSERT

Input
[{"id":1,"name":"Alice"}]
Output
INSERT INTO "users" ("id", "name") VALUES ($1, $2);
Bindings: [[1, "Alice"]]

Identifiers are quoted and values are separate bindings.

Nested value

Input
[{"id":1,"meta":{"tier":"pro"}}]
Output
Bindings: [[1, "{\"tier\":\"pro\"}"]]

Nested objects become JSON strings suitable for a text or jsonb column.

About this tool

JSON to SQL Converter turns JSON records into parameterised SQL statements. Rather than pasting values straight into a string, it emits placeholders and returns the matching bindings, so quotes, backslashes and Unicode never corrupt a statement.

Three statement modes cover the common data-loading jobs: INSERT for new rows, UPDATE for changes keyed by a column, and UPSERT with dialect-specific conflict clauses. Identifiers are quoted for PostgreSQL, MySQL or SQLite, and the table name may be schema-qualified.

Nested objects and arrays are serialized as JSON strings for text or jsonb columns, missing fields become NULL bindings, and an optional column subset controls exactly which fields are written. Conversion happens in the browser; only the SQL you copy or download leaves the tab.

What this tool does not do

  • No CREATE TABLE / DDL generation and no statement execution.
  • Nested values are serialized as JSON strings; casting to jsonb is left to the caller.
  • Integer precision beyond JavaScript's safe-integer range can be lost by JSON.parse.
  • Very large inputs produce large SQL text and binding arrays bounded by browser memory.

How to use this tool

  1. Paste JSON records

    Paste an array of objects or a single object. Each object becomes one SQL statement.

  2. Set the statement shape

    Choose INSERT, UPDATE or UPSERT, a table name, a key column for the latter two, and an optional comma-separated column subset.

  3. Choose a dialect

    PostgreSQL uses $n placeholders and double-quoted identifiers; MySQL uses backticks; SQLite uses double quotes and ? placeholders.

  4. Copy SQL and bindings

    Copy or download the SQL, and open the bindings panel to pass the values to your database client as a separate array.

Use cases

Seed a test database

Turn an API response into INSERT statements and bindings for a fresh schema.

Build fixture scripts

Generate UPDATE statements keyed by id for repeatable test setup.

Load extracts across engines

Re-emit the same JSON for PostgreSQL, MySQL or SQLite without rewriting escapes.

Dialect differences

DialectIdentifiers
PostgreSQL"name"
MySQL`name`
SQLite"name"

Each statement carries its own binding array, so PostgreSQL numbering restarts at $1 per statement.

Common mistakes

Mistake:Pasting bindings into SQL text as literals.

Fix:Pass the bindings array to your client's query call; the SQL contains placeholders on purpose.

Mistake:Expecting CREATE TABLE statements.

Fix:This tool only emits INSERT, UPDATE and UPSERT; define the schema separately.

Mistake:Using a key column that is absent from the data.

Fix:Set a key column that exists, or accept the fallback to the first column reported in the warnings.

Frequently asked questions

Why are values separate from the SQL?

Parameterised statements avoid escaping bugs and SQL injection. The SQL text contains only placeholders; the bindings panel shows the value array to pass to your database client.

Which SQL dialects are supported?

PostgreSQL, MySQL and SQLite. They differ in identifier quoting ("name" vs `name`), placeholder style ($n vs ?) and the upsert conflict clause.

How are nested objects and missing fields handled?

Objects and arrays become JSON strings suitable for text or jsonb columns. A field absent from a row is bound as NULL, and the warning strip reports missing columns.

Can I choose which columns are written?

Yes. Enter a comma-separated list in Columns; only those fields, in that order, are emitted. Columns that do not appear in the data are ignored with a warning.

Does it run my SQL or upload my data?

Neither. The tool only generates text in this browser tab; no connection is made to a database and nothing is uploaded.

References & standards