CSV to SQL INSERT
Turn the rows of a CSV into INSERT statements for your database, with the right quoting and optional CREATE TABLE. The data is processed in your browser.
- No usage limits
- Your data stays local
- PostgreSQL, MySQL, SQL Server
- Empty cells become NULL
- Runs on your device. Files are never uploaded.
- Free and unlimited. No sign-up, no watermark.
CSV to SQL INSERT in three steps
No account, no email, no waiting for an upload.
- STEP 01
Add your CSV
The header row names the columns.
- STEP 02
Set the table and database
Enter the table name, pick the database type, rows per INSERT, and whether to add CREATE TABLE.
- STEP 03
Copy the SQL
Run it in your database client after a quick review.
What CSV to SQL INSERT does, and what it doesn't
We'd rather tell you up front than surprise you after the download.
What you get
- Quoting that fits your databaseIdentifiers use double quotes, backticks or square brackets. Strings have quotes doubled, and MySQL backslashes are escaped.
- Typed valuesNumbers and true/false are written without quotes when typed values are on. Leading-zero codes stay as strings.
- Empty cells as NULLBlank cells are written as NULL rather than empty strings.
- Batch sizeGroup rows into multi-row INSERTs. SQL Server is capped at 1,000 rows per statement.
- CREATE TABLE draftOptionally add a table definition with guessed types such as INTEGER, BIGINT, DOUBLE PRECISION, BOOLEAN or TEXT.
Good to know
- Schema is a draftNo keys, constraints or indexes are generated. Review types, especially for dates, which are stored as text.
- Test firstRun generated SQL on a copy before touching real data.
- Large filesFor hundreds of thousands of rows, a database import command is faster. Split the file with the CSV splitter if you need smaller scripts.
Your data never leave your device
The tool runs inside your browser instead of on our servers, so there is nothing to upload, store or delete afterwards.
Typical online tool upload
Your file travels over the internet, sits on someone else's computer for a while, and you wait for the upload and the download.
Mediaextractr no upload
The tool loads into your browser once, then works on your file locally. Nothing is sent, so nothing can leak.
When people use CSV to SQL INSERT
Seed a database from a spreadsheet
Load reference data without writing an import script.
Create test data
Turn a table of cases into repeatable SQL.
Migrate a small dataset
Move a sheet into a relational table.
Practice SQL
Build a sample table from open data.
Mediaextractr vs typical upload tools
| MediaextractrPrivate | Typical upload tools | |
|---|---|---|
| Your file is uploaded | Never | Yes |
| Sign-up needed | No | Often, after a few files |
| Daily file limit | None | Often 1–2 free files |
| Watermark | Never | Sometimes |
| Wait for upload & download | No | Yes |
| Speed on very large files | Depends on your device | Depends on their servers |
How the SQL is built
Each header becomes a column name, quoted for your database. Rows are grouped into statements such as INSERT INTO t (a, b) VALUES followed by comma-separated rows in parentheses. Text is wrapped in single quotes with inner quotes doubled.
If you tick Add CREATE TABLE, column types are guessed from the values in each column. A column of whole numbers becomes INTEGER, or BIGINT if any number is large.
Make the script safer
Small steps reduce risk:
- Pick the right database so quoting and booleans match.
- Check that header names are sensible. Spaces and symbols are quoted, but plain names are easier to query.
- Use a transaction for large loads.
- Tidy the script with the SQL formatter, or shrink it with the SQL minifier.
- Starting from JSON? Use JSON to SQL INSERT.
Loading the script: CSV to SQL INSERT
Run the SQL in your client or with psql, mysql or sqlcmd. For repeat loads, add TRUNCATE or a DELETE at the top, or use a staging table and merge from it. Check row counts afterwards against the note in this tool. Mismatches usually point to rows rejected by constraints you added later.
Questions, answered
How do I convert CSV to SQL INSERT statements?
Paste the CSV, set the table name and database type, and copy the generated SQL.
Does generating INSERT statements upload my CSV rows?
No. The SQL is generated by script in this page. Rows with personal data are never sent to a server.
How are empty cells written?
As NULL.
Does it escape quotes?
Yes. Single quotes inside values are doubled, and MySQL backslashes are escaped.
Can it create the table?
Yes. Tick 'Add CREATE TABLE' for a basic definition with guessed types.
Can I generate INSERT statements on a tablet or phone?
Yes, in current mobile browsers, though pasting a long script into a database client is easier on a computer.