CSV to SQL

CREATE TABLE with inferred types and INSERTs for MySQL, Postgres, SQLite, SQL Server.

About this tool

Paste CSV with a header row, drop a CSV file, or paste a JSON array of objects. Choose the database, table name and rows per INSERT, and whether to include CREATE TABLE and DROP TABLE IF EXISTS. The SQL appears with a summary of each column's inferred type; copy it or download a .sql file.

How types are inferred and values escaped

Every column is scanned: whole numbers become INTEGER (or BIGINT beyond 2,147,483,647), numbers with a decimal point DECIMAL or NUMERIC, true/false BOOLEAN, ISO dates DATE and date-times TIMESTAMP or DATETIME; anything else is text, sized to the longest value (VARCHAR up to 255, TEXT beyond). Mixed columns widen safely โ€” integers and decimals become decimals, dates and timestamps become timestamps, anything else becomes text. Values with leading zeros, such as zip codes, account numbers and โ€˜007โ€™, stay text so nothing is lost. Single quotes are doubled, empty cells become NULL, and identifiers are quoted the way each database expects โ€” backticks for MySQL, double quotes for PostgreSQL and SQLite, square brackets for SQL Server. Rows are batched into multi-row INSERTs, which load much faster than one statement per row. Honest notes: inference only sees the rows you paste, so check the types before loading production data, and for very large files your database's bulk loader โ€” COPY in PostgreSQL, LOAD DATA in MySQL โ€” is faster still. The CSV viewer inspects the file first, the SQL formatter tidies queries, CSV to JSON converts the other way, and CSV vs Excel: what each file really contains, and what breaks in between covers CSV quirks.

Frequently asked questions

Which databases are supported?

MySQL and MariaDB, PostgreSQL, SQLite and Microsoft SQL Server โ€” each with its own identifier quoting and type names.

Why is a numeric column created as text?

Because at least one value isn't a plain number, or values have leading zeros (like 00123) that a number type would drop.

Can I convert JSON to SQL?

Yes. Paste a JSON array of objects; the keys become columns and nested values are stored as JSON text.

Is my data uploaded?

No. Parsing and conversion happen entirely in your browser.