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
Free tool, nothing to install

CSV To SQL Converter
Data To SQL And Back Again

This CSV to SQL converter turns CSV, TSV and JSON into CREATE TABLE and INSERT statements. It also reads SQL rows back into JSON, CSV, XML, YAML and HTML. We upload nothing.

  • 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.
The short version

What A CSV To SQL Converter Does For You

You often have data in a spreadsheet, and you need it in a database. Typing one INSERT line per row would take hours. So you need a tool that writes the SQL 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.

It also works the other way, and that direction is the one people need again a week later. Paste SQL with INSERT rows, and the tool reads them back as JSON, CSV, TSV, XML, YAML or an HTML table. So you can move data into a database and out of it.

Everything runs in your browser. So your data never leaves your device. That matters, because exports often hold customer names, emails and prices.

CSV To SQL, Step By Step

First, paste CSV with a header row. The tool reads the delimiter for you, so comma, semicolon, tab and pipe files all work. So each header becomes a column name.

Drawing of a CSV table on the left and an arrow to CREATE TABLE and INSERT statements on the right
CSV rows become INSERT statements.

Then it looks at the values in each column. A column of whole numbers becomes 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 differ in small ways, and those details break imports. So the tool writes the dialect you pick. MySQL uses backticks around names. PostgreSQL and SQLite use double quotes. SQL Server uses square brackets and an N before text.

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

Also, types change. A true or false column is BOOLEAN in PostgreSQL, TINYINT in MySQL and BIT in SQL Server. The tool picks the right one.

Then text gets a safe length, such as 50, 100 or 255. Very long text becomes TEXT. SQLite is relaxed about types, so there the tool uses plain INTEGER, REAL and TEXT.

SQL To JSON, CSV And More

First, paste a script with INSERT statements and pick another format. The tool reads every row, and it uses the column list or the CREATE TABLE to name the columns.

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

Also, if the script holds several tables, a list lets you pick one. NULL becomes null in JSON and an empty cell in CSV. Numbers and true or false keep their type.

Also, it reads multi row inserts, escaped quotes and N strings. It does not run anything, and it ignores statements that carry no rows.

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 nested objects and lists turn into JSON text in one column. That keeps the table flat and loses nothing.

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, empty cells become 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 reads SQL as text. It never connects to a database and never runs a statement. It also draws results as text, so a hostile file cannot run code in your page.

How it works

Using The CSV To SQL Converter, Step By Step

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

  • 1

    Paste your data

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

  • 2

    Pick two formats

    Choose what you have and what you want. Swap them with one click.

  • 3

    Set the options

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

  • 4

    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, 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

    Your browser does the work. We never see 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 work in every 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 it in a transaction. 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 stay 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.

  • Uploading private files

    Many converters send your file to a server. This one never does.

Questions

CSV To SQL Converter Questions People Ask

Is this CSV to SQL converter free?

Yes. It costs nothing, needs no account and has no limits. It runs in your browser, so we have no server cost to pass on.

Is my data uploaded anywhere?

No. Your browser reads the data and writes the result. Nothing reaches this site, and we keep nothing.

Which databases does it support?

MySQL, PostgreSQL, SQL Server and SQLite. Each one gets its own quoting and its own column types.

Which formats can it read?

CSV, TSV, JSON and SQL. It writes SQL, JSON, CSV, TSV, XML, YAML and an HTML table.

How does it pick the column types?

It checks every value in a column. Whole numbers become integers, decimals become floating point, and dates and booleans get their own types. Everything else becomes text.

Can I change the table name?

Yes. Type it in the table name box. When you read SQL, the box shows the table from the script.

What does Rows per INSERT do?

It groups rows into one statement. One row per statement is the safest. Ten, a hundred or all rows load faster.

What happens to empty cells?

They become NULL by default. Switch the option off to write empty strings instead.

How are quotes handled?

Every single quote in a value is doubled. In MySQL, backslashes are doubled too.

Does it keep leading zeros?

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

Can I convert JSON to SQL?

Yes. Use a list of flat objects. Each key becomes a column, and missing keys become NULL.

What about nested JSON?

A nested object or list is written as JSON text in one column.

Can I convert SQL to JSON?

Yes. Paste INSERT statements and pick JSON. The tool reads every row and uses the column names.

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 reads the text only. It never connects to a database.

Why did I get an error?

The text may have a broken quote, bad JSON or no INSERT rows. The message tells you which one.

Can I open a file?

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

How big a file can I use?

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

Does it add a primary key?

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?

Paste it into your database client and run it. Test it on a copy first.

Which values count as dates?

Values such as 2026-02-19 and 2026-02-19 10:30:00 become dates. Other formats stay text.

Does it work on a phone?

Yes. The panels stack and the boxes scroll. For long data, a keyboard is still easier.

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.