CSV to SQL

Paste CSV or JSON rows and generate SQL CREATE TABLE plus INSERT statements. Infer column types, pick a SQL dialect, choose literal or placeholder values, and keep everything local in your browser.

Try:
SQL

What this tool does

Paste a CSV, delimited text, or JSON table and generate runnable SQL: an optional DROP TABLE IF EXISTS, a CREATE TABLE with inferred column types, and INSERT statements for every row. It runs entirely in your browser, so the table data is not uploaded.

Use it when you need a quick import script for seed data, a database migration snippet, a fixture file, or a handoff from spreadsheet-style data to SQL.

Input formats

Blank CSV cells, JSON null, and missing JSON keys become NULL by default. Set Blank/null cells to default or empty-string when you need a different literal.

Dialects and value modes

Choose MySQL, PostgreSQL, SQLite, SQL Server, or ANSI SQL. The dialect controls identifier quoting, boolean literals, placeholder syntax, and the CREATE TABLE type names. Inferred categories include integer, float, boolean, date, datetime, and text. Zero-padded codes such as ZIP/postal codes stay as text so leading zeroes are not lost.

The default literal mode escapes values and writes complete SQL. Choose placeholder to produce a prepared-statement shape (?, $1, @p1, etc.) with a trailing -- params: comment showing the bound values.

Example

Input CSV:

id,name,score,active,joined
1,Alice,9.5,true,2024-01-02
2,Bob,7,false,2024-02-10

With table users, dialect mysql, and primary key id, the output starts:

CREATE TABLE `users` (
  `id` INT,
  `name` TEXT,
  `score` DOUBLE,
  `active` TINYINT(1),
  `joined` DATE,
  PRIMARY KEY (`id`)
);
INSERT INTO `users` (`id`, `name`, `score`, `active`, `joined`) VALUES
(1, 'Alice', 9.5, 1, '2024-01-02'),
(2, 'Bob', 7, 0, '2024-02-10');

Limits and edge cases

FAQ

Can it generate both CREATE TABLE and INSERT statements?

Yes. Include CREATE TABLE is on by default, and it uses inferred column types. You can turn it off when you only need INSERT statements for an existing table.

How are column types inferred?

Each column is scanned across non-blank values. Integers, floats, booleans, dates, and datetimes are recognized when every populated value fits that type. Otherwise the column becomes text. Zero-padded numeric-looking values stay text.

Which SQL dialect should I choose?

Pick the database that will run the SQL. The dialect changes identifier quotes, boolean values, prepared-statement placeholders, and data types such as TIMESTAMP, DATETIME, REAL, and BIT.

What is placeholder mode for?

Placeholder mode emits a prepared statement shape instead of inline literals. For example PostgreSQL uses $1, $2, and SQL Server uses @p1, @p2. The bound values are shown in a trailing -- params: comment for easy copying into application code or tests.

Will blank cells become empty strings?

Not by default. Blank CSV cells, JSON null, and missing JSON fields become NULL. Change Blank/null cells to empty-string for '', or default for the SQL DEFAULT keyword.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool csv-to-sql "id,name,score,active,joined
1,Alice,9.5,true,2024-01-02
2,Bob,7,false,2024-02-10"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/csv-to-sql/?input=id%2Cname%2Cscore%2Cactive%2Cjoined%0A1%2CAlice%2C9.5%2Ctrue%2C2024-01-02%0A2%2CBob%2C7%2Cfalse%2C2024-02-10&format=auto&delimiter=auto&has_header=true&table=users&dialect=mysql&values=literal&multi_row=true&create_table=true&drop_table=true&primary_key=id&quote_identifiers=true&null_handling=null&infer_types=true&detect_dates=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.