Turn a CSV into CREATE TABLE, INSERT, UPDATE or UPSERT statements for PostgreSQL, MySQL, SQLite, SQL Server or Oracle, with types detected and every value escaped.
Initializing in your browser…
Open a CSV as a sortable, searchable table, edit cells, rows and columns with undo, and download the result. Runs in your browser.
Convert CSV to JSON or JSON back to CSV, keeping zip codes, IDs and quoted text exactly as written and listing anything the conversion changes.
Convert a CSV to an Excel .xlsx or OpenDocument .ods workbook with real number, currency, percentage and date cells, while keeping zip codes and IDs exactly as written.
A shop's product list has SKUs with leading zeros, a name with an apostrophe, prices, yes/no stock flags, ISO dates and two empty notes. It needs to go into PostgreSQL.
products.csv
id,sku,product,price,in_stock,added_on,notes 1,00731,Children's picture book,12.99,yes,2024-01-15,Hardcover 2,01842,"Desk lamp, brass",48.50,yes,2024-02-03, 3,10027,Wireless mouse,19.99,no,2024-02-28,Back in March
PostgreSQL
BEGIN;
CREATE TABLE "products" (
"id" INTEGER PRIMARY KEY,
"sku" VARCHAR(50) NOT NULL,
"product" VARCHAR(50) NOT NULL,
"price" NUMERIC(4,2) NOT NULL,
"in_stock" BOOLEAN NOT NULL,
"added_on" DATE NOT NULL,
"notes" VARCHAR(50)
);
INSERT INTO "products" ("id", "sku", "product", "price", "in_stock", "added_on", "notes") VALUES
(1, '00731', 'Children''s picture book', 12.99, TRUE, '2024-01-15', 'Hardcover'),
(2, '01842', 'Desk lamp, brass', 48.50, TRUE, '2024-02-03', NULL),
(3, '10027', 'Wireless mouse', 19.99, FALSE, '2024-02-28', 'Back in March');
COMMIT;The SKU column holds 00731, so it is typed VARCHAR and the zeros survive; as an integer it would have stored 731. Price needs two whole digits and two decimals, so it is NUMERIC(4,2), and 48.50 is written with its trailing zero. yes and no become TRUE and FALSE, the apostrophe in Children's is doubled, and the empty note becomes NULL, which is why notes is the only column created without NOT NULL. The id column is named id and holds distinct whole numbers, so it is offered as the primary key. Switch the database to Oracle and the same rows come out as one INSERT each with DATE '2024-01-15' literals.
Load a CSV and get a ready-to-run SQL script for PostgreSQL, MySQL, SQLite, SQL Server or Oracle. Column types are detected from the data, every name and value is quoted the way that database expects, and anything that could not be carried over exactly is listed before you run it.
From file to script in one step. Drop in a CSV, pick a database, and the script appears below, updating as you change settings. You can create the table and insert the rows, insert into a table that already exists, write UPDATE statements that change existing rows matched on a key column, or write an UPSERT that adds new rows and updates the ones already there. PostgreSQL and SQLite get ON CONFLICT, MySQL gets ON DUPLICATE KEY UPDATE, and SQL Server and Oracle get MERGE.
Column types from the data. Each column is typed by what all of its values have in common. Whole numbers become INTEGER or BIGINT, decimals become DECIMAL or NUMERIC sized to the widest value so nothing is rounded, true/false and yes/no become a boolean, ISO dates such as 2024-03-15 become DATE, and everything else becomes text with room to spare. Values with leading zeros, like ZIP codes and product codes, stay text so 02134 is not stored as 2134. Dates written as 03/04/2024 stay text as well, since they mean different days in different countries. Any type, name, key or default can be changed in the column editor.
Names and values written safely. Every table and column name is quoted, so headers like order, first name or unit price (USD) work as they are. A name that is empty, too long for the database, or a duplicate of another is renamed and reported. Text is escaped for the database you chose: apostrophes are doubled everywhere, backslashes are doubled only for MySQL, which treats a backslash as an escape character, and SQL Server and Oracle get N'...' literals for text outside plain ASCII. Spaces at the start or end of a value are kept, and the word NULL in a cell stays text unless you list it as a placeholder.
Scripts that run the first time. Rows shorter than the header are padded, rows that are longer get extra columns, and a column that will receive empty values is never created as NOT NULL. Inserts are batched, 100 rows per statement by default, with SQL Server kept under its limit of 1000 rows per statement and Oracle given one statement per row. An auto-numbered key keeps the ids from your file: SQL Server gets IDENTITY_INSERT, and PostgreSQL and Oracle have their sequence moved past the highest id so new rows do not collide. Oracle dates are written as DATE literals, which do not depend on session settings. The script can be wrapped in a transaction so a failure leaves nothing half loaded.
Private by design. The file is read and the SQL is written in your browser. Nothing is uploaded and no database connection is made: copy the script, or download it as a .sql file and run it with the client you already use.
Turn a spreadsheet of sample customers or products into a script that creates the table and fills it, ready to run in psql, the MySQL client, SQL Server Management Studio or the sqlite3 shell.
Export a table to CSV from one system and generate a script in the other's dialect, with types and quoting that suit the target rather than the source.
When someone hands you a sheet of corrected prices or statuses, generate UPDATE statements matched on the ID or SKU column instead of editing rows by hand.
The script shows exactly how each value will be written, and the notes call out renamed columns, values that do not fit their type and anything else worth a second look.
In the sample file the SKU column (00731, 01842) is typed VARCHAR so the zeros survive, price becomes NUMERIC(4,2), in_stock with yes and no becomes BOOLEAN with TRUE and FALSE, and the apostrophe in Children's picture book is doubled.
Choose UPDATE existing rows and match on sku. Each row becomes one UPDATE that sets the other columns from the file WHERE "sku" = '00731', and rows with an empty key are pointed out because they would match nothing.
With 25,000 rows and All in one selected, the inserts are split into 25 statements of 1000 rows, because SQL Server refuses a longer VALUES list. With the default batches of 100 you get 250 statements.
PostgreSQL, MySQL (and MariaDB), SQLite, SQL Server and Oracle. Each gets its own identifier quotes, string escaping, type names, boolean values and upsert syntax, so pick the one you will actually run the script on.
From the values in each column. If every non-empty value is a whole number the column is INTEGER (or BIGINT for very large numbers), if every value is a decimal it becomes DECIMAL or NUMERIC with enough digits for the largest one, and ISO dates become DATE. Anything mixed becomes text, sized at about twice the longest value. You can change any type in the column editor.
Because at least one value starts with a zero, such as 02134 or 00731. A numeric column would store those as 2134 and 731 and the zeros would be gone for good. Keeping the column as text preserves the codes exactly.
By default an empty field becomes NULL. Under More options you can make it an empty string instead, and name a placeholder such as N/A or a dash that should also become NULL. A cell holding only spaces is written as those spaces, and the word NULL stays text unless you name it as a placeholder.
Choose the column that identifies each row, usually an ID or SKU. UPDATE writes one statement per row that sets every other column WHERE the key matches. UPSERT inserts the row or, if the key already exists, updates it. For PostgreSQL, SQLite and MySQL the key column must have a primary key or unique constraint in the existing table.
Yes. Apostrophes are doubled, MySQL backslashes are doubled because MySQL reads them as escapes, and names are always quoted with their own quote characters escaped. A NUL byte, which no database accepts inside a string literal, is removed and reported.
Nothing is uploaded; the script is built in your browser, so the limit is your device's memory. Files with tens of thousands of rows work well. For very large scripts the on-page preview shows the beginning, while Copy and Download always include every statement.
Rows and columns are parsed and transformed in memory in your browser. No record ever reaches a server.