Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free tool, nothing to install

CSV To SQL Converter
CSV and JSON to SQL and Back

The CSV-to-SQL converter converts CSV, TSV, and JSON data into CREATE TABLE and INSERT commands. The converter can also read the data from a SQL database table and convert it into JSON, CSV, XML, YAML, and HTML. All conversion is done locally; we never send your data to our servers.

  • FreePrice
  • 4Databases
  • NoneSign-up
  • NoneUploads

CSV to SQL Converter

Turn CSV and JSON into SQL, or SQL INSERT rows into data

Rows
0
Columns
0
Size
0 B

Ready. Paste your data and pick the formats.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.

Run it on a test page before the live one

Keep a copy of your original code and try the result on a test page before you replace the live file. No automatic tool can see every way your site uses its code.

Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

The short version

What A CSV To SQL Converter Does For You

When you’ve got your data in a spreadsheet but want to load it into a database, you’ll be spending a great deal of time creating individual "INSERT" statements for each row of data. This is where you’ll want to find a tool to create those "INSERT" statements for you.

This tool does that in one box. First, paste your CSV, TSV or JSON. Then pick SQL as the target, and choose the table name and the database. The CREATE TABLE and INSERT statements appear as you type.

This works both ways. The other way is what people need about a week later. When you paste SQL that has INSERT rows into the tool, the tool reads them back as JSON, CSV, TSV, XML, YAML or an HTML table. So, you can put data into your database and take data out of your database.

Your work will always remain within your browser and so on your own computer. This is important since many exports contain client names, email addresses, and price info.

From CSV To SQL, Step By Step

You can first copy and paste your CSV file with a header row. The program will automatically work out the delimiter used in your file (comma, semicolon, tab or pipe) and create columns from each header.

Drawing of a CSV table on the left and an arrow to CREATE TABLE and INSERT statements on the right
Every CSV row becomes an INSERT statement.

Then it looks at the values in each column. A column of whole numbers turns into an integer. A column with decimals becomes a floating point number. Dates, true and false, and short or long text each get their own type.

Finally, it writes the statements. You get one CREATE TABLE with the columns and one INSERT line per row, or fewer lines if you batch the rows.

For more detail, see: Wikipedia article on SQL INSERT.

Pick Your Database

Databases vary slightly, which is why when importing data it can be difficult. The software will create the appropriate dialect based on your selection. When using MySQL, backticks (`) are placed around name fields. Double quotes are used around name fields when using PostgreSQL and SQLite. Square brackets and an "N" are used before text fields when using SQL Server.

CSV to SQL converter turning a CSV of orders into a PostgreSQL CREATE TABLE and INSERT statements
CSV in, PostgreSQL out.

As types change. A true/false column is a BOOLEAN type in PostgreSQL, TINYINT type in MySQL and BIT type in SQL Server. The tool will select the appropriate type.

After that, the text has a safe length (e.g., 50, 100, or 255). Long texts will be converted into TEXT. Since SQLite is flexible about data types, the tool will use plain INTEGER, REAL and TEXT.

SQL To JSON, CSV And More

First, copy and paste a script containing INSERT statements and select an alternative format. The tool will then process each row, using either the column list or the CREATE TABLE statement to work out column names.

SQL INSERT statements on the left and the same rows as a JSON list on the right
INSERT rows read back as JSON.

Also, a list will allow you to select from the different tables that are contained within the script. NULL is converted to null in JSON, and an empty cell in CSV. Numbers, true, and false will retain their original data types.

Also, it parses multiple row inserts, single-quote escapes, and N strings. It will not execute any SQL commands and will ignore all SQL commands which do not produce results.

JSON To SQL

A JSON list of flat objects works too. Then each key becomes a column, and the tool joins the keys of all objects. So a missing key becomes NULL.

So you will get all your nested objects and list data as JSON strings in a single column. This keeps the table flat while still keeping all of your data intact.

Quotes, NULL And Batches

The tool doubles every single quote in text, so a name such as O'Neil cannot break the statement. In MySQL it also doubles backslashes.

First, blank cells turn into NULL by default. Switch that off if you want empty strings. Also, numbers stay bare, and text stays in quotes.

Then you can write one INSERT per row, or group ten, a hundred or all rows in one statement. Grouped inserts load faster on big tables. So use them for large files.

Keep Zeros And Long Ids Safe

A ZIP code such as 02134 would lose its zero as a number. So the tool keeps a value with a leading zero as text. It also keeps very long ids as text, because a number type would round them.

Safe By Design

First, the tool parses SQL as text. It does not open a database connection and does not execute a SQL statement. The tool also outputs all of its results as text. So, a malicious file cannot cause code to be executed on your website.

Video guide

The CSV to SQL Converter in Action

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

How it works

Using The CSV To SQL Converter, Step By Step

Four steps take you from a file to a database script.

  • Paste your data

    Paste CSV, TSV, JSON or SQL, open a file, or try the sample.

  • Pick two formats

    Choose the initial format as well as the desired output format. You can easily switch between both formats using just one click.

  • Set the options

    Choose the table name, the database and how many rows go in each INSERT.

  • Copy or save

    Copy the result, or save it with the right file type.

Why this one

What This SQL Converter Does Differently

It goes both ways, it knows four databases, and it keeps your data private.

  • Both directions

    Data to SQL, and SQL rows back to data.

  • Four databases

    MySQL, PostgreSQL, SQL Server and SQLite are all covered, each in its own style.

  • Smart types

    Integers, decimals, dates, booleans and text of the right length.

  • Safe quoting

    Every quote in a value gets doubled, so no value can break a statement.

  • Batch inserts

    One row per line, or ten, a hundred or all rows per INSERT.

  • Nothing leaves your tab

    The work is done on your end, in your browser. Our team does not have access to any of your data.

Good habits

Habits For Loading Data Into A Database

A few habits keep an import safe.

  • Clean the CSV first. Trim spaces and remove blank rows before you convert.
  • Keep the header row. Column names turn into table columns, so they must be clear.
  • Use simple column names. Letters, digits and underscores are safe in any database.
  • Check the types. Read the CREATE TABLE and change a type if you need a different one.
  • Add a primary key. A key column makes later updates and joins easy.
  • Batch big files. Group rows into one INSERT to load thousands of rows faster.
  • Test on a copy. Run the script on a test database before the real one.
  • Mind the character set. Use UTF-8 so accents and other scripts survive the import.
  • Keep zeros as text. ZIP codes and phone numbers belong in text columns.
  • Wrap the import in a transaction so you can roll it back. Start with BEGIN and end with COMMIT, so a failure leaves nothing half loaded.
  • Mind private data. Remove personal columns before you share a script.
Worth avoiding

Common Import Mistakes This Tool Prevents

Each of these quietly damages an import. The converter guards against them.

  • Broken quotes

    A name with an apostrophe gets its quote doubled.

  • Lost leading zeros

    ZIP codes and phone numbers are saved as text.

  • Wrong identifier quotes

    Each database gets its own style of quoted names.

  • Empty strings in numbers

    Empty cells become NULL, so a number column stays clean.

  • Wrong boolean type

    True and false map to the right type for your database.

Questions

Common Questions About The CSV To SQL Converter

Does this CSV to SQL converter cost anything?

Yes, it is free, does not need an account, and does not have any limits. Since your computer processes the data, there will be no cost incurred by us for processing that data.

Does my data ever reach a server?

No. The browser will read the data and output the result. No data is sent to us, nor do we store any.

Which databases can the generated SQL run on?

Each of these database management systems — MySQL, PostgreSQL, SQL Server, and SQLite — will get their own set of rules for quoting and column types.

Which input file types will the CSV to SQL converter read?

It reads CSV, TSV and JSON files, as well as SQL. It writes SQL, JSON, CSV, TSV, XML, YAML and an HTML table.

How does it pick the column types?

The process of checking each value within a column will convert all whole numbers into integers, all decimal values into floating-point numbers, and each date and boolean into its own unique type. Everything else becomes text.

Can I give the table a different name?

Yes. Type it into the table name field. The field displays the table being referenced in your SQL script when you view the script.

What does Rows per INSERT do?

Rows are combined into single statements. Each row as its own statement gives the greatest safety. Loading ten, one hundred or every row will give the fastest load times.

How does the converter treat empty CSV cells?

Unless you change it, they turn into NULL. Switch the option off to write empty strings instead.

How are quotes handled?

Every time there is a single quotation mark within a value, it will be doubled. Also, every backslash used in MySQL will be doubled.

Will leading zeros in codes and IDs survive the trip into SQL?

Yes. A value such as 00123 stays text, so the zeros survive.

Can JSON be converted to SQL?

Yes. Use a list of flat objects. You get a column for each key. Missing keys are given NULL values.

What about nested JSON?

Nested objects and lists are saved as JSON text in one column.

Can I convert SQL to JSON?

Yes, paste the insert statement(s) and select "JSON". The tool will read each line of data and use the column headers.

What if my SQL has several tables?

A list appears, and you pick the table you want to read.

Does it run my SQL?

No, it always reads the exact same text you give. And it never connects to any other computer or database.

Why did the converter show an error message?

The text could contain a broken quote, an incorrect JSON format, or no rows to be inserted. The error message will find the exact problem.

Can I open a file rather than paste?

Yes. Use Open a file. The tool picks the input format from the file type.

What is the biggest file the tool will accept?

A few megabytes. Very large files may read slowly on a phone.

Does the converter add a primary key column?

No. It writes plain columns. Add a key by hand, because the right key depends on your data.

How do I load the script into my database?

You can use this script to run against a copy of your database before running it against the actual database. To do so, paste the script into your database client and execute.

Which values count as dates?

For example, 2026-02-19 and 2026-02-19 10:30:00 will be represented as dates. All other formats will remain in string form.

Does it run on phones too, or only on desktops?

Yes, the panels are stacked, and the boxes can be scrolled. If there is a large amount of data to enter, then using a keyboard will be simpler.

More free tools

Handy Companions For Data Work

Converting is one step. These three tools handle the steps around it.

Ready To Convert Some Data?

Paste your data, pick two formats, and copy the result. The converter is free, needs no account, and keeps every byte on your device.

Prefer Denwix on GoogleReview Denwix on Google