JSON to SQL INSERT Generator
Convert a JSON array of objects into SQL INSERT statements. The union of all keys becomes the column list.
Pure browser JavaScript — no external libraries.
How to use this tool
- Paste a JSON array of objects, or upload a .json file.
- Type the target table name and choose single or multi-row mode.
- Click Generate SQL, then Copy or Download the .sql file.
Convert a JSON array of objects into SQL INSERT statements. The union of all keys becomes the column list.
How it works
This tool converts a JSON array of objects into SQL INSERT statements. It collects the union of all keys across every object to build the column list, then generates one INSERT per object, filling NULL for any missing keys.
Paste your JSON array and enter the target table name. The tool detects strings, numbers, booleans, and nulls, applying correct SQL quoting and escaping. The output is ready to run in most SQL databases.
Use this when you have API response data, a JSON seed file, or a database backup in JSON format that you need to restore or import into a relational database.
All processing happens in the browser with no data transmitted.
Worked example
Import a JSON user list into a SQL users table
- Paste the JSON array of user objects into the input.
- Enter users as the table name.
- Click Generate SQL.
- Copy the output and run it in your database client.
INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com'); — one statement per object.
Common mistakes to avoid
- Passing a single JSON object instead of an array — wrap it in [ ] brackets.
- Expecting nested arrays within objects to expand into separate rows — they become a single text value.
- Not checking that the generated column list matches your actual table schema before running the INSERT statements.
Key terms
- Key union
- The full set of keys found across all objects in the array; objects missing a key get NULL for that column.
- NULL
- The SQL representation of a missing or unknown value, distinct from an empty string or zero.
- Boolean literal
- In SQL, true and false (or 1 and 0 in some dialects) represent JSON boolean values.
Frequently asked questions
- What if objects have different keys?
- The column list is the union of every object's keys; missing keys become NULL for that row.
- How are types mapped?
- Numbers and booleans are emitted unquoted (TRUE/FALSE); nested objects/arrays are JSON-stringified into a quoted string; null becomes NULL.