CSV to SQL Insert
Turn a CSV into INSERT statements: numbers stay numbers, blanks become NULL, and quotes are escaped. No upload.
What CSV to INSERT does
The first row is the column list and every later row becomes one VALUES tuple, so a thousand rows are one statement rather than a thousand round trips. A value that is a number is written unquoted, an empty cell becomes NULL, and everything else is a quoted string with the apostrophe doubled — which is what makes O'Brien survive. A leading zero keeps the column a string, because 007 is a code rather than the number seven. A short row is padded with NULL; a long row is an error, since a value with nowhere to go is a data bug.
How to use it
CSV to SQL Insert: paste the CSV into the box above, set Table name (default "data"), and press Run to get the SQL below.
Worked example
Input:
id,name,role
1,Ada,admin
2,"O'Brien",author
3,Grace,
Output:
INSERT INTO data (id, name, role) VALUES
(1, 'Ada', 'admin'),
(2, 'O''Brien', 'author'),
(3, 'Grace', NULL);
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads CSV and returns SQL; reloading the page discards both.
The first row is the column list and every later row becomes one VALUES tuple, so a thousand rows are one statement rather than a thousand round trips. A value that is a number is written unquoted, an empty cell becomes NULL, and everything else is a quoted string with the apostrophe doubled — which is what makes O'Brien survive. A leading zero keeps the column a string, because 007 is a code rather than the number seven. A short row is padded with NULL; a long row is an error, since a value with nowhere to go is a data bug.
Turn a CSV into INSERT statements: numbers stay numbers, blanks become NULL, and quotes are escaped. No upload.
How to use it
CSV to SQL Insert: paste the CSV into the box above, set Table name (default "data"), and press Run to get the SQL below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads CSV and returns SQL; reloading the page discards both.
What to Expect
Best for
- Converting CSV to SQL when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
id,name,role 1,Ada,admin 2,"O'Brien",author 3,Grace,
Sample output
INSERT INTO data (id, name, role) VALUES (1, 'Ada', 'admin'), (2, 'O''Brien', 'author'), (3, 'Grace', NULL);
Frequently asked questions
How do I use the csv to sql insert?
CSV to SQL Insert: paste the CSV into the box above, set Table name (default "data"), and press Run to get the SQL below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.