JSON to SQL

Generate INSERT-style SQL statements from JSON arrays.

Loading Smart Logic...

Quick Tip

Paste a JSON object, or an array of objects where each object is one row.

About This Tool

Why use JSON to SQL?

Turn a JSON array into INSERT statements for a table you name. Each object becomes one INSERT, string values are escaped by doubling any apostrophes, and column names are quoted so that a key with a space, a hyphen or a reserved word still produces valid SQL.

Real exports are rarely uniform, so the column list is the union of every key across all rows rather than just the keys of the first object. A row that is missing a key gets NULL for that column instead of shifting every value after it into the wrong field — which is exactly the failure that makes hand-rolled converters dangerous. Nulls become NULL, booleans become TRUE and FALSE, and nested objects are stored as JSON text rather than as [object Object].

Key Benefits

Columns from every row

The column list is the union of all keys, so rows with missing fields get NULL rather than a value landing in the wrong column.

Values escaped correctly

Apostrophes in text are doubled, nulls become NULL, booleans become TRUE and FALSE, and nested objects are stored as JSON text.

Identifiers quoted

Column names are quoted, so keys containing spaces, hyphens or SQL reserved words still produce valid statements.

How to use JSON to SQL

  1. 1

    Paste a JSON object, or an array of objects where each object is one row.

  2. 2

    Set the target table name.

  3. 3

    Generate; one INSERT statement is produced per row.

  4. 4

    Review the SQL, then run it against a test database before production.

Best use cases

Load API response data into a database table.

Generate seed data for a migration from a JSON fixture.

Move a JSON export into a SQL-based reporting system.

Create test rows quickly without writing INSERT statements by hand.

JSON to SQL FAQs

What happens if my objects have different keys?

The column list covers every key seen across all rows, and any row missing a key gets NULL for it. Nothing shifts into the wrong column.

Are quotes in my text escaped?

Yes. Apostrophes inside string values are doubled, which is the standard SQL escape, so a value like O'Brien produces valid SQL.

How are nested objects and arrays handled?

They are stored as JSON text in a single column. SQL has no nested value type, so a nested structure has to be flattened or serialised — this serialises it.

Which SQL dialect does it produce?

Standard INSERT syntax with double-quoted identifiers, which works in PostgreSQL and SQLite as-is. MySQL needs backticks rather than double quotes unless ANSI_QUOTES mode is on.

Related Data Tools

More free data tools that work well alongside json to sql.