CSV to SQL INSERT Generator
Turn a CSV into SQL INSERT statements for any table name, with automatic number/boolean detection and quoting.
Pure browser JavaScript. CSV parsing by PapaParse (MIT), self-hosted.
How to use this tool
- Paste CSV or upload a .csv file with a header row.
- Type your target table name and choose options.
- Click Generate SQL, then Copy or Download the .sql file.
Turn a CSV into SQL INSERT statements for any table name, with automatic number/boolean detection and quoting.
How it works
This tool converts a CSV file into a series of SQL INSERT statements, ready to paste into a database client or migration script. The first CSV row is used as column names, and each subsequent row becomes one INSERT statement.
Enter your target table name, paste or upload the CSV, and click Generate. The tool automatically detects numeric and boolean values and omits quotes around them, while wrapping string values in single quotes with proper SQL escaping for apostrophes.
This is particularly useful for seeding a database with test data, migrating data between environments, or creating reproducible data setup scripts without needing a full ETL pipeline.
The output runs entirely in your browser. No data is sent anywhere, making it safe for use with sensitive seed data.
Worked example
Generate INSERT statements to seed a products table
- Paste a CSV with headers: id, name, price, in_stock.
- Enter products as the table name.
- Click Generate SQL.
- Copy the INSERT statements.
- Paste them into your database client or migration file.
INSERT INTO products (id, name, price, in_stock) VALUES (1, 'Widget A', 9.99, true); — one statement per row.
Common mistakes to avoid
- Forgetting to set the correct table name before generating, then having to find-and-replace it in the output.
- Having NULL values represented as the string NULL in the CSV, which the tool may quote as a string rather than treating as SQL NULL.
- Using reserved SQL keywords as column names without quoting them — rename the column in the CSV header first.
Key terms
- INSERT statement
- A SQL command that adds one or more rows of data into a specified table.
- SQL string escaping
- Replacing a single quote inside a value with two single quotes so it does not break the SQL syntax.
- Type detection
- The tool's ability to tell whether a CSV value should be inserted as a number, boolean, or quoted string.
Frequently asked questions
- How are strings escaped?
- Single quotes inside values are doubled ('') and the whole value is quoted, the SQL-standard way. Identifiers are wrapped in double quotes.
- What is the multi-row option?
- It emits one INSERT with many VALUES tuples, which is faster to run than one statement per row in most databases.