CSV to SQL Converter

Generate SQL INSERT, CREATE TABLE, and UPDATE statements from CSV data. Supports MySQL, PostgreSQL, SQLite, and SQL Server with auto-detected column types.

100% client-side. Your data never leaves your browser.

In Laravel

The generated SQL is right for a one-off import that you paste into a database client. When the import must run again, for example on every migrate:fresh --seed, read the CSV in a seeder instead.

A lazy collection reads the file one row at a time, so a large CSV does not fill memory. Each chunk of 500 rows becomes one INSERT query.

use Illuminate\Support\Facades\DB;
use Illuminate\Support\LazyCollection;

public function run(): void
{
    LazyCollection::make(function () {
        $handle = fopen(database_path('data/products.csv'), 'r');
        $header = fgetcsv($handle, escape: '');

        while (($row = fgetcsv($handle, escape: '')) !== false) {
            // fgetcsv() returns [null] for a blank line
            if ($row !== [null]) {
                yield array_combine($header, $row);
            }
        }

        fclose($handle);
    })
        ->chunk(500)
        ->each(fn (LazyCollection $rows) => DB::table('products')->insert($rows->all()));
}

Pass escape: '' to fgetcsv(). Since PHP 8.4, leaving out the escape argument is deprecated, and the empty string follows the CSV standard (RFC 4180). If a row can already exist, use upsert() in place of insert().

Laravel 13.x docs: Seeding, Lazy collections, Insert statements

Multi-Dialect

Generate SQL for MySQL, PostgreSQL, SQLite, and SQL Server. Each dialect uses correct quoting, data types, and syntax conventions.

Type Detection

Automatically detects column types: INTEGER, DECIMAL, BOOLEAN, DATE, and VARCHAR. Used for CREATE TABLE and proper value quoting.

Batch & Transaction

Single or batch INSERT mode, optional DROP TABLE, transaction wrapping, and empty-to-NULL conversion for production-ready SQL.

Need something custom built?

I build custom Laravel tools, web apps, and SaaS platforms. If you need something beyond off-the-shelf, let's talk.

Contact

Frequently Asked Questions

Why did the leading zeros disappear from my postcodes?

A column where every value is digits gets the type INTEGER, and the values go into the SQL without quotes. The database then stores 00184 as 184. The same happens to phone numbers and product codes. Change those columns to VARCHAR in the CREATE TABLE statement and quote their values.

Why are my dates rejected or wrong after the import?

The converter marks a column as DATE when the values look like 2026-10-10 or 10/10/2026, but it copies the values as they are. MySQL in strict mode rejects a value like 25/12/2026, and PostgreSQL reads 01/02/2026 as January 2 with its default settings. Change the dates to YYYY-MM-DD in your spreadsheet first, or import the column as text and convert it afterwards.

My CSV from Excel uses semicolons. What do I change?

Select "Semicolon" as the delimiter. Excel in many European locales saves CSV with semicolons, because there the comma is the decimal separator. Prices like 12,50 then stay text, because the converter only detects decimals with a dot.