JSON or CSV to SQL INSERT
Turn a JSON array or a CSV file into multi-row INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server, batched, with optional upsert.
Free · No sign-up · Your inputs stay in your browser
Input
Generate SQL INSERT statements from JSON or CSV
Output
SQL
2 rows, 5 columns, 1 statement
Values are written as literals with quotes doubled, so the output is safe to run as a one-off script. Application code should use bound parameters; Laravel's DB::table()->insert() and upsert() do it for you.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Batching
One multi-row INSERT is much faster than the same rows inserted one by one, because each statement costs a round trip and a commit when autocommit is on. Very large statements hit limits instead: MySQL rejects a packet larger than max_allowed_packet, 64 MiB by default in MySQL 8.0 and later. A few hundred to a few thousand rows per statement is a safe range.
Upserts differ by database
MySQL's ON DUPLICATE KEY UPDATE fires on any unique index; PostgreSQL and SQLite's ON CONFLICT (column) names the constraint to check. Laravel's upsert() hides the difference, and needs a unique index on the columns you pass, or every row is inserted.