SmartQueryTools

Convert Excel to SQL Online

Convert Excel files to SQL INSERT statements directly in your browser. Copy or download the generated SQL — no upload required.

About converting Excel to SQL

Excel to SQL turns a sheet into a script you can run in PostgreSQL, MySQL, SQLite or SQL Server. It is handy for seeding a development database, loading a reference table like country codes or price bands, or handing a small dataset to a developer as something they can paste straight into a migration.

The script has one CREATE TABLE IF NOT EXISTS statement followed by one INSERT per row. The table is named after the workbook file, with spaces and symbols turned into underscores. Column types are chosen from the detected types: whole numbers become BIGINT, decimals DOUBLE PRECISION, true and false BOOLEAN, dates DATE, date-times TIMESTAMP, and everything else TEXT. Real Excel dates become DATE in any display format. Dates typed as text may end up as TEXT. The script covers the first 1,000 rows of the first sheet, and the page shows a notice when the sheet has more.

Review the script before running it. Columns with currency formatting are typed TEXT and their values keep symbols like $, so an import into a numeric column will fail. Header names are double-quoted, which keeps spaces valid in PostgreSQL and SQLite. MySQL only accepts double-quoted names with ANSI_QUOTES enabled. For more than 1,000 rows, convert to CSV and use your database's bulk loader, such as COPY or LOAD DATA.

Worked example

A small orders export with an ID, a customer name, a date, an amount (one missing) and a true/false flag, converted with the default settings.

Input (Excel)

Excel workbook, first sheet (Sheet1)

order_idcustomerorder_dateamountshipped
1001Acme Ltd2026-03-02249.5true
1002Brightside Co2026-03-021200false
1003Acme Ltd2026-03-0589.99true
1004Northwind2026-03-07NULLfalse

Output (SQL)

CREATE TABLE IF NOT EXISTS "data" (
  "order_id" BIGINT,
  "customer" TEXT,
  "order_date" DATE,
  "amount" DOUBLE PRECISION,
  "shipped" BOOLEAN
);

INSERT INTO "data" VALUES (1001, 'Acme Ltd', '2026-03-02', 249.5, true);
INSERT INTO "data" VALUES (1002, 'Brightside Co', '2026-03-02', 1200, false);
INSERT INTO "data" VALUES (1003, 'Acme Ltd', '2026-03-05', 89.99, true);
INSERT INTO "data" VALUES (1004, 'Northwind', '2026-03-07', NULL, false);

What changes when you convert Excel to SQL

  • The table name comes from the file name, so Orders Q1.xlsx creates "Orders_Q1".
  • order_id becomes BIGINT, amount DOUBLE PRECISION, order_date DATE and shipped BOOLEAN.
  • Text values are wrapped in single quotes, and apostrophes are doubled, so O'Brien becomes 'O''Brien'.
  • Order 1004's empty amount is inserted as NULL.
  • Only the first 1,000 data rows are included in the script.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Frequently Asked Questions

Why does the SQL stop at 1,000 rows?

The script is built and shown in the page as text, and very large scripts are slow to render and to run as single INSERTs. For bigger sheets, convert to CSV and load it with COPY, LOAD DATA or your database's import tool.

Will the script work in MySQL?

The INSERT values do, but column and table names are quoted with double quotes. Enable ANSI_QUOTES in MySQL, or replace the double quotes with backticks before running it.

Can I add a primary key?

The generated CREATE TABLE has no keys or constraints. Edit the statement before running it, for example by adding PRIMARY KEY after the order_id column type.

What is SQL format?

SQL (Structured Query Language) is the standard language for querying and manipulating relational databases. The output contains CREATE TABLE and INSERT INTO statements ready to run against any SQL-compatible database.

Related Tools