JSON to SQL INSERT Generator
Convert JSON or CSV to SQL INSERT statements and CREATE TABLE for MySQL, PostgreSQL, SQL Server and SQLite, with safe quoting and batching. Runs in your browser.
How to use JSON to SQL
- 1Paste JSON or CSV, choose the input format and open More options if you need them.
- 2Pick the dialect, table name, batch size and whether to include CREATE TABLE.
- 3Read the SQL, then copy it or download it as inserts.sql.
What makes it better
- MySQL, PostgreSQL, SQL Server and SQLite quoting rules
- Column names and the table name are quoted with the quote character doubled
- Single quotes in values are doubled (backslashes too for MySQL)
- Column types inferred: INTEGER, BIGINT, floating point, boolean and text
- One INSERT per row or multi-row batches
About JSON to SQL
JSON to SQL turns an array of JSON objects, or a CSV file with a header row, into CREATE TABLE and INSERT statements in the dialect you choose. Identifiers are quoted and string values escaped, and column types are guessed from the data. It writes SQL as text for you to review and never connects to a database or runs anything.
Common uses
- Seed a local development database from a JSON fixture or an API sample.
- Load a small CSV export into a staging table without writing a script.
- Prepare test rows for a SQL Server or SQLite database in one paste.
- Check what a JSON structure would look like as relational columns.
Example
Input
[{"id":1,"name":"Asha","active":true},{"id":2,"name":"O'Reilly","active":false}]Result
CREATE TABLE `my_table` ( `id` INTEGER, `name` VARCHAR(255), `active` BOOLEAN ); INSERT INTO `my_table` (`id`, `name`, `active`) VALUES (1, 'Asha', TRUE), (2, 'O''Reilly', FALSE);
Good to know
- The output is SQL text for you to read. Review it before running it, and in application code use parameterised queries instead of pasting values into SQL.
- Types are guesses from the data you pasted (for example a column of whole numbers becomes INTEGER). Adjust them for production, and add keys, indexes and constraints yourself.
- Nested JSON objects become columns joined with an underscore and arrays are stored as JSON text. At most 50,000 rows are included, and SQL Server batches are limited to 1,000 rows.
JSON to SQL FAQ
Is the generated SQL safe against SQL injection?
Identifiers are wrapped in the dialect's quotes with any quote character inside doubled, and string values have single quotes doubled, so a hostile column name or value stays inside its quotes. That only protects the text this page writes. Always read the SQL before running it, and use parameterised queries in your own code.
How are booleans and NULL written for each database?
MySQL and PostgreSQL get TRUE and FALSE, while SQL Server and SQLite get 1 and 0. JSON null becomes NULL, and an empty CSV cell becomes NULL unless you turn that off under More options.
How does it choose column types?
Whole numbers become INTEGER, or BIGINT beyond 2,147,483,647. Other numbers become DOUBLE, DOUBLE PRECISION, FLOAT or REAL depending on the dialect. Booleans use the native type where there is one, and everything else is VARCHAR(255) or NVARCHAR(255), switching to TEXT or NVARCHAR(MAX) for values longer than 255 characters.
What does the batching option change?
One INSERT per row gives the easiest statements to retry or edit, while larger batches put many rows into a single INSERT ... VALUES list, which runs faster in a database. SQL Server rejects more than 1,000 rows in one VALUES list, so batches are capped there.
Can I use a schema-qualified table name?
Yes. Typing public.users quotes each part separately, giving "public"."users" in PostgreSQL. Any other characters in the name are kept but quoted, so they cannot end the identifier early.