ModernCalcs

CSV to SQL INSERT

Convert CSV data into SQL INSERT statements. Specify a table name, choose a SQL dialect (MySQL backticks or ANSI quotes), and numbers are left unquoted automatically.

CSV Input

SQL Output

INSERT INTO "users" ("name", "age", "city", "department", "salary") VALUES ('Alice', 30, 'New York', 'Engineering', 95000);
INSERT INTO "users" ("name", "age", "city", "department", "salary") VALUES ('Bob', 25, 'San Francisco', 'Design', 78000);
INSERT INTO "users" ("name", "age", "city", "department", "salary") VALUES ('Charlie', 35, 'Austin', 'Marketing', 82000);

CSV to SQL INSERT: Bulk Data Loading Made Easy

Importing CSV data into a relational database usually means writing INSERT statements by hand or using a slow import wizard. This tool converts your CSV directly to ready-to-run INSERT statements — numbers unquoted, strings escaped, table and column names quoted for your chosen dialect.

Formula
INSERT INTO `users` (`name`, `age`, `city`) VALUES ('Alice', 30, 'New York');

Numbers are inserted unquoted. Strings are single-quoted with internal single quotes escaped by doubling (''). Column and table names are quoted by the selected dialect.

MySQL vs ANSI SQL Quoting

MySQL uses backticks (`) to quote identifiers — table names and column names — which is non-standard but required for MySQL/MariaDB. ANSI SQL (PostgreSQL, SQLite, SQL Server, Oracle) uses double quotes ("). Select the mode that matches your target database.

Type Detection

Any cell value that JavaScript parses as a valid number is inserted without quotes, making it compatible with INT, FLOAT, and DECIMAL columns. Everything else is treated as a string and single-quoted. Empty cells produce empty string values ('') — if you need NULL, do a post-process find-and-replace.

One Statement Per Row

Each CSV data row produces one INSERT statement on its own line. This format is compatible with all SQL clients, works well for pasting into a query editor, and can be run incrementally — if one row fails, the others are not affected.

Practical Examples

Seeding a Users Table

Import a users.csv export into a fresh database table.

  • 1.Paste the CSV with name, email, and age columns
  • 2.Enter your table name (e.g. 'users')
  • 3.Choose MySQL or ANSI SQL dialect
  • 4.Copy the INSERT statements and run in your SQL client

What Gets Generated

  • One INSERT INTO statement per data row
  • Column list from the CSV header row
  • Numbers as bare numeric literals
  • Strings single-quoted with escaped apostrophes

Good Use Cases

  • Seeding development databases from spreadsheet data
  • Bulk-inserting exported rows from one DB to another
  • Generating test fixtures from CSV exports
  • Loading reference data into a clean schema

Frequently Asked Questions

How are strings and numbers handled?

Any cell value that parses as a valid number is inserted without quotes. All other values are wrapped in single quotes, and any single quotes inside the value are escaped by doubling them ('').

What is the difference between MySQL and ANSI SQL mode?

MySQL mode wraps table and column names in backticks (`). ANSI SQL mode uses double quotes ("). Most other databases (PostgreSQL, SQLite, SQL Server) accept ANSI quoting.

Does this support NULL values?

Empty cells are currently inserted as empty strings. If you need NULLs, leave the cell as empty and do a post-process find-and-replace on '' → NULL in the output.