CSV / JSON to SQL INSERT

A tool that converts a CSV with headers or a JSON array of objects into PostgreSQL INSERT statements for loading a test database. You can set the table name and columns, and review how strings are escaped and how NULL is handled before using the output. The SQL can be copied or saved as a file — all processed in your browser.

Your data is never sent to a server — SQL is generated entirely in your browser. No database connection is made and nothing is executed.
Table and column names are wrapped in double quotes, keeping case and symbols as-is.
Rows per statement
How values are written (check before using)
  • Every value is written as a string (leading zeros are kept).
  • Single quotes (') inside strings become ''. Backslashes are written as-is (assumes standard_conforming_strings = on).
  • Empty cells are written as empty strings ('') by default. Check the option below to write NULL instead.
INSERT statements (PostgreSQL)

Output uses PostgreSQL syntax. Other databases may handle quoting differently.

How to use

  1. Choose the input format (CSV or JSON), then paste the data or load a file.
  2. Enter the table name (and a schema name if needed), and choose the columns to include.
  3. Check the escaping and NULL rules under "How values are written". You can choose how empty CSV cells and missing JSON keys are handled here.
  4. "Copy" the generated INSERT statements or use "Save SQL file".

About this tool

Rewriting CSV or JSON into INSERT statements by hand to load test data is tedious and error-prone — it's easy to miss escaping a quote. With this tool, you paste the data and get correctly quoted INSERT statements.

Single quotes inside strings are escaped as '', and table and column names are wrapped in double quotes as identifiers. CSV values are treated as strings by default, so leading zeros such as in postal codes are kept, and empty cells never silently become NULL. JSON null, numbers, booleans, and strings are kept distinct, and rows with missing keys or nested values are reported as errors.

Only PostgreSQL syntax is supported for now. No database connection is made, no SQL is executed, and UPSERT is not supported. Your data is never sent to a server.

Choose JSON input, paste [{"id":1,"name":"O'Brien"}], set the table to users, and select id and name. The output is INSERT INTO "users" ("id", "name") VALUES (1, 'O''Brien');. The numeric 1 stays unquoted, while the apostrophe in the name is doubled.

CSV input would treat the same 1 as a string, so JSON is useful when explicit value types matter. Generation is a local text transformation and does not insert rows into a database. Check the target constraints and defaults before executing the result.

Frequently asked questions

Why are CSV numbers written as strings?

CSV has no type information, so every value is written as a string to avoid losing leading zeros or large numbers. PostgreSQL converts a string like '123' automatically when it's inserted into a numeric column.

What happens to JSON rows with missing keys?

By default, the row and key are reported as an error and nothing is filled in silently. You can change "Rows where a key is missing" to insert NULL or DEFAULT (the column default) instead.

Does it work with MySQL or SQLite?

Only PostgreSQL is supported for now. Identifier quoting and backslash handling differ between databases, so the output may not work as-is elsewhere.