JSON to SQL
Convert a JSON array of flat objects into portable SQL INSERT statements. Keys become columns (union of all objects, first-seen order), and values are typed and escaped correctly: strings are single-quoted with doubled apostrophes, NULLs stay NULL, numbers and booleans are emitted bare (booleans as 1/0 for portability), and nested objects or arrays are serialised as JSON strings. Choose the table name and optionally emit CREATE TABLE or wrap the inserts in a transaction.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
From JSON array to INSERT statements
Paste a JSON array of flat objects and the tool writes one SQL INSERT per object (or a single multi-row INSERT), plus an optional CREATE TABLE. The keys of your objects become the columns — the union of every key, kept in the order they were first seen — so rows that omit a key simply get NULL in that column and the statements stay aligned across all rows. Identifiers are quoted and strings escaped so the SQL copy-pastes without hand-fixing.
When this beats hand-writing SQL
Loading a small fixture into a test database, seeding a demo, or moving an API response into a table are the classic cases. Generation is deterministic and types are inferred, so you avoid the usual mistakes — a missing apostrophe escape, mismatched column counts between rows, or a boolean written as "true" where Postgres wants true or MySQL wants 1.
Options and what they change
Table sets the target name and must be a plain identifier. Dialect switches between standard double-quoted identifiers and MySQL backtick quoting. Emit CREATE TABLE adds a table definition with a type inferred per column from the values it saw. One INSERT with multiple VALUES rows collapses everything into a single statement, and the transaction switch wraps the output in BEGIN; and COMMIT; (on by default).
How values are written
Strings are single-quoted with internal apostrophes doubled, which is valid across PostgreSQL, MySQL and SQLite. Numbers and booleans are emitted bare, with booleans as 1 or 0 for portability. null becomes NULL. Nested objects and arrays have no SQL column equivalent here, so they are serialised as JSON strings in the cell rather than silently flattened.
Your data is not sent anywhere
The array is parsed and the statements are generated locally in this tab. Nothing is uploaded and no database is contacted, which is what makes it safe to turn a private export into insert statements here.
Questions
How are values escaped?
Single quotes in strings are doubled ('O''Brien'), which is valid across PostgreSQL, MySQL and SQLite. Nested objects and arrays are emitted as JSON strings; null stays NULL; booleans become 1/0.
What if objects have different keys?
Columns are the union of all keys in first-seen order. Rows missing a key emit NULL for that column, so the generated INSERTs stay aligned.
Which SQL dialect?
Standard quoting works for PostgreSQL, SQLite and MySQL. Pick the MySQL option if you prefer backtick-quoted identifiers.
Related tools
See categoryCSV to SQL INSERT
Turn a CSV table into INSERT statements for MySQL, Postgres, SQLite or any SQL database.
JSON to CSV
Turn a JSON array of objects into CSV, with delimiter, header, and flatten options.
SQL Formatter (basic)
Pretty-print a SQL query: keyword casing, clause line breaks, indented joins and columns.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.