CSV TO SQL

Turn a CSV into a .sql file of INSERT statements, with an optional CREATE TABLE, for PostgreSQL, MySQL, SQLite, or SQL Server. Column types can be detected from the data, empty cells can become NULL, and quotes are escaped correctly. Nothing is run against any database; the tool only writes the file.

Zero retention: your files never leave this browser. Verify it yourself in DevTools.

Loading the CSV tools.

About CSV to SQL converter

How Can You Verify That Your Files Never Leave This Browser?

You do not have to take our word for it. Browser developer tools list every request a page makes, so you can watch 2csv work and confirm that your data is never sent anywhere. The check takes about a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files (including the background file parser), its web fonts, and one anonymous page-view request. No file has been chosen yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Open a CSV file in the CSV to SQL converter tool above, run it, and download the result.
  5. Look at the Network tab again. It is still empty. Reading, changing, and saving the file made no request at all. For extra proof, turn on offline mode after the page loads: every tool keeps working.

Your file is read into this tab's memory with the browser's own file reader, parsed and changed by code that is already on the page, and handed back to you as a download. It is never uploaded, never stored in the browser, and gone when you close the tab. The only other request the site can make is the feedback form, and only when you submit it.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so even a bug could not send your data elsewhere.

Which Options Does CSV to SQL Have?

  • Dialect: PostgreSQL, MySQL, SQLite, or SQL Server, which sets identifier quoting as "x", `x`, or [x], and N'' strings for SQL Server.
  • Table name: the name used in every statement.
  • CREATE TABLE: optional, written before the inserts.
  • Rows per INSERT: 1, 100, 500, or 1000. SQL Server allows at most 1000.
  • Empty cells as NULL: write NULL instead of an empty string.

Single quotes inside values are escaped by doubling them, so a name such as O'Brien is written safely and cannot break out of the string. The live preview in the export bar shows the real first statements with your settings, so you can check quoting and types before downloading.

How Are Column Types Detected?

With type detection on, each column gets a type from its values. Whole numbers become BIGINT or INTEGER, decimals become NUMERIC, DOUBLE, REAL, or FLOAT depending on the dialect, true/false columns become BOOLEAN or BIT, and dates become DATE written as ISO values. Anything else is text. With detection off, every column is text.

  1. Clean money and dates first with the column type converter.
  2. Turn on type detection and check the CREATE TABLE in the preview.
  3. Adjust the table name and rows per INSERT, then download.

Does CSV to SQL Run Anything?

No. The tool writes text into a .sql file and nothing else. It does not connect to a database, does not run the statements, and does not run SQL queries against your CSV. You run the file yourself in your own database client, where you can review it first. That keeps credentials and data entirely on your side.

How Big Can the SQL Output Be?

As big as the table. Grouping 500 or 1000 rows per INSERT keeps the file smaller and loads faster than one statement per row. Use one row per INSERT when you want a failing row to be easy to find. If a filter is on, only the matching rows are written, which is a quick way to load a subset.

For very large tables, cutting the CSV into parts first with the CSV splitter and converting each part gives several smaller .sql files that are easier to load one at a time.

What Else Can You Do With a CSV Here?

  • CSV viewer: Open a CSV of any size, scroll every row, and see a profile of each column.
  • Sort CSV: Sort rows by one or more columns, as text, numbers, or dates, ascending or descending.
  • Filter CSV: Show only the rows that match an expression such as price > 10 AND state = "NY".
  • CSV validator: Find ragged rows, broken quotes, bad headers, encoding problems, and values of the wrong type.
  • Remove duplicates from CSV: Find and remove duplicate rows, comparing whole rows or only the columns you choose.
  • Trim CSV whitespace: Trim leading and trailing spaces, collapse double spaces, and drop invisible characters and empty rows.
  • Find and replace in CSV: Find text in one column or every column and replace it, with match case, whole cell, and regex options.
  • Remove rows from CSV: Delete rows by number or range, the first or last rows, empty rows, or rows that match a rule.
  • CSV editor: Edit cells, add or delete rows, and add, delete, rename, or move columns.
  • Split CSV column: Split one column into several at a delimiter, such as a full name into first and last.
  • Merge CSV columns: Join two or more columns into one with the separator you choose, skipping empty values.
  • CSV column type converter: Convert a column to clean numbers, ISO dates, true/false, or upper, lower, or title case.
  • CSV to JSON converter: Convert CSV to a JSON array of objects or arrays, or to JSON Lines, with typed values.
  • JSON to CSV converter: Convert a JSON array or JSON Lines to CSV, flattening nested objects into dotted column names.
  • CSV to TSV converter: Convert a comma-separated file to tab-separated values that paste cleanly into spreadsheets.
  • TSV to CSV converter: Convert a tab-separated file to a standard, properly quoted comma-separated CSV.
  • CSV splitter: Split a large CSV into smaller files of a set number of rows, with the header repeated in each.

All eighteen tools are on the 2csv home page, and once a file is open you can switch between them without reloading it. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

Does it connect to my database?

No. It only writes a .sql file. You run the statements yourself in your own database client.

Which databases are supported?

PostgreSQL, MySQL, SQLite, and SQL Server. The dialect sets identifier quoting, string style, and column type names.

How are apostrophes in values handled?

Single quotes are escaped by doubling them, so a value such as O'Brien is written safely inside the statement.

Why is SQL Server limited to 1000 rows per INSERT?

SQL Server rejects a single INSERT with more than 1000 rows of values, so the tool caps it there.

Can empty cells be written as NULL?

Yes. Turn on empty cells as NULL and blank cells are written as NULL instead of an empty string, which suits numeric and date columns.

Was this helpful?