- Tools
- CSV to SQL Converter
Free tool
CSV to SQL Converter
Paste CSV data and get ready-to-run CREATE TABLE and INSERT statements, with a type picked for each column. Choose your database and copy the result. Everything runs in your browser.
CREATE TABLE "users" (
"id" INTEGER,
"name" TEXT,
"email" TEXT,
"age" INTEGER,
"active" BOOLEAN,
"signed_up" DATE
);
INSERT INTO "users" ("id", "name", "email", "age", "active", "signed_up") VALUES
(1, 'Alice Ng', 'alice@example.com', 30, TRUE, '2024-01-15'),
(2, 'Bob "The Builder" Ray', 'bob@example.com', 25, FALSE, '2024-02-20'),
(3, 'Carol Woods', 'carol@example.com', 42, TRUE, '2024-03-05');From spreadsheet export to a real table
A CSV export is easy to produce and awkward to load. Before the rows can live in a database you need a table to hold them, with a sensible type on every column, and then an INSERT for the data itself. Doing that by hand for anything wider than a few columns is slow and error prone.
This converter reads your CSV, uses the header row for column names, and looks at the values in each column to choose a type. It then writes the CREATE TABLE and the INSERT statements together, so you can paste both straight into a client and run them.
How the column types are chosen
Each column is inspected across every row, not just the first one. A column where every value is a whole number becomes an integer type. Add a decimal point anywhere and it becomes a floating point type instead. Columns holding only true and false values become a boolean, and values written as YYYY-MM-DD become a date, or a timestamp when a time is attached.
When a column mixes formats, or holds anything the tool cannot place with confidence, it falls back to a text type. That keeps the generated SQL safe to run: a text column accepts any value, so nothing is lost if the guess is conservative. Empty cells become NULL rather than an empty string.
Built for the database you use
The dialect setting changes two things: the column type names and the way identifiers are quoted. PostgreSQL and SQLite quote names with double quotes, MySQL uses backticks, and SQL Server uses square brackets. Booleans are written as TRUE and FALSE for PostgreSQL and as 1 and 0 where that is the convention.
The whole conversion happens in your browser, so a customer export or any other sensitive file stays on your machine. Nothing is uploaded and nothing is saved.
Frequently asked questions
- How do I convert CSV to SQL?
- Paste your CSV into the left pane. The tool reads the header row for column names, infers a type for each column, and writes a CREATE TABLE statement plus INSERT statements you can copy and run. Pick your database dialect first so the types and quoting match.
- Does it detect column types?
- Yes. Each column is scanned across every row. If all values are whole numbers it becomes an integer type, decimals become a floating point type, true and false values become a boolean, and dates in YYYY-MM-DD form become a date or timestamp. Anything else falls back to a text type.
- Can I convert CSV without a header row?
- Yes. Turn off the "First row is a header" option and the tool treats every line as data, naming the columns column_1, column_2, and so on. You can rename them in the generated SQL afterwards.
- Does it handle commas and quotes inside values?
- Yes. The parser follows the common CSV rules, so a value wrapped in double quotes can contain commas and line breaks, and a doubled double quote inside a quoted value is read as a single quote character. Values with apostrophes are escaped correctly for SQL.
- Which databases are supported?
- The output can target PostgreSQL, MySQL, SQLite, SQL Server, or standard SQL. The dialect controls the column type names and how identifiers are quoted, for example double quotes for PostgreSQL, backticks for MySQL, and square brackets for SQL Server.
- Is my CSV uploaded anywhere?
- No. The conversion runs as JavaScript in your browser, so your data stays on your machine. You can paste real exports without them being sent to a server.
More free tools
Import CSV straight into DB Pro
Generating SQL is one way to load a file. DB Pro gives you another: open a table and import a CSV directly, with a preview and column mapping, no statements to write. It is a desktop database client for macOS, Windows, and Linux that works with PostgreSQL, MySQL, SQLite, and more.
Keep exploring the free tools, or read the database tutorials and cheat sheets.