JSON to SQL
Turn JSON arrays into SQL INSERT statements with object keys as column names.
Add JSON and click Convert to see the SQL here.
How JSON to SQL works
Turns a JSON array of objects into SQL INSERT statements. Each object becomes a row, and each key becomes a column. Keys are collected from all objects, so objects do not need the same keys.
Numbers, true/false and null keep their type. Nested objects and arrays are saved as JSON text, in a JSON column for MySQL and JSONB for PostgreSQL.
Input to JSON to SQL
- Paste or type JSON into the input box, or upload or drop a .json or .txt file. A single object gives one row.
- Pick the database: MySQL, PostgreSQL, SQLite or SQL Server. Table sets the table name, and Rows per INSERT can be 1, 100, 500 or 1000.
- Add CREATE TABLE puts a table definition before the inserts, with column types guessed from your values.
- Input must be valid JSON. If it is not, you see the line and column of the first error. Files up to 20MB, and everything runs in your browser.
Output from JSON to SQL
- SQL with syntax highlighting. Missing keys and null become NULL. Empty strings stay as empty text.
- Names and values are quoted and escaped for the database you pick.
- Copy it, download it as output.sql or open it in full screen. Use SQL to JSON to go the other way.