CSV to SQL converter
Turn a CSV file into CREATE TABLE and INSERT statements for PostgreSQL, MySQL, SQL Server or SQLite. Runs in your browser; nothing is uploaded.
About this converter
Getting a spreadsheet into a database is one of those tasks with three bad options and no good one. Your database client's import wizard guesses column types badly. Writing a loader script means half an hour on something you will throw away. And hand-writing INSERT statements is fine for five rows and unbearable for five hundred.
This converter takes the third option and does it for you. Paste your CSV or drop a file, and you get a CREATE TABLE statement with inferred column types followed by the INSERT statements to populate it, in the dialect you choose: PostgreSQL, MySQL, SQL Server or SQLite.
Type inference is deliberately conservative, because the failure mode of guessing wrong is silent data corruption. A column becomes an integer type only if every value is a whole number and none has a leading zero, which keeps zip codes, phone numbers and zero-padded IDs as text where they belong. Columns of mixed content widen to VARCHAR or TEXT rather than forcing a cast that would fail halfway through your import.
Identifiers are quoted unconditionally for the chosen dialect. It costs nothing and it removes the entire class of problems where a column happens to be called order, group, or select. Values have their single quotes doubled, which is the standard escape everywhere here.
One thing to be clear about: generated SQL is for a seed file or a migration you are going to read before running. It is not a substitute for parameterised queries in application code, and the output carries a header saying so. Review before you execute, particularly if the CSV came from somewhere you do not control.
The conversion runs entirely in your browser, so a customer export or an internal report never leaves your machine.
Frequently asked questions
- Why is my numeric column typed as text?
- Because at least one value has a leading zero or is not a whole number. That is intentional - treating a zero-padded ID as an integer destroys it, so the converter widens to text instead.
- Can I change the table name?
- The output uses my_table. Find and replace it once in your editor - a single replace is less error-prone than an option that has to escape an arbitrary name for four dialects.
- Is this safe against SQL injection?
- Quotes are escaped by doubling, which is correct for a file you review before running. It is not a security boundary. Never pipe untrusted CSV straight into a database through generated SQL.
- What is the difference between one multi-row INSERT and one per row?
- A single multi-row INSERT is much faster to execute. Separate statements are easier to run partially or to debug when one row fails.