Excel to SQL Query Logo
EXCEL TO SQL QUERYexceltosqlquery.com
GuideFAQ

Documentation

Excel and CSV to SQL Guide

Step-by-step guidance for preparing spreadsheet data and generating typed SQL output for your target database dialect.

Conversion guide

Turn spreadsheet rows into typed SQL

This online Excel and CSV to SQL converter creates SQL text for database seeding, test data, and one-off imports. Use the converter above to paste tabular data or open an Excel or CSV file, review the inferred columns, and generate a script for your chosen database.

Process data in your browser

Your file is parsed in the browser where you opened the converter. The app does not upload spreadsheet rows to a conversion service, connect to a database, or run generated SQL. Review the output before using it in your own database client or migration workflow.

How to convert Excel or CSV to SQL

  1. Paste rows or choose an Excel, CSV, or TSV file.
  2. Select MySQL, PostgreSQL, or SQLite and enter a table name.
  3. Check the detected types and correct any column mapping.
  4. Resolve validation messages, then generate, copy, or download the SQL.

Choose the dialect that matches your database

DatabaseIdentifiersJSON outputBoolean output
MySQLBackticksJSON column type in CREATE TABLETRUE / FALSE
PostgreSQLDouble quotesJSONB with ::jsonb castsTRUE / FALSE
SQLiteDouble quotesTEXT column type1 / 0

Map each column to the right SQL type

Auto-detection provides a starting point for text, integers, decimals, dates, timestamps, Booleans, and JSON. You retain control: select a type for each column when the spreadsheet’s values need a different interpretation. Empty cells can become NULL, an empty string, or a custom default.

For example, map active to Boolean and profile to JSON instead of treating both as ordinary text. The preview lets you check the result before generating SQL.

Validate data before generating

The validator checks selected types against each non-empty cell. Invalid JSON and values that cannot be read as integers, decimals, dates, timestamps, or Booleans are shown with their row and column, so you can fix a value or adjust the mapping before creating a script.

SQL text values are escaped for the selected dialect. JSON values are parsed and normalized when valid, including PostgreSQL JSONB casts.

Generate INSERT statements and optional table definitions

The default output is a multi-row INSERT statement. Choose CREATE TABLE + Multi-row INSERT when you also need a table definition based on the selected types. You can split output into batches of 100, 500, or 1,000 rows, or keep all rows in one statement. If you select a primary key and UPSERT mode, the generator adds the supported conflict syntax for the selected dialect.

INSERT INTO "users" ("id", "active", "profile") VALUES
  (101, TRUE, '{"role":"admin"}'::jsonb),
  (102, FALSE, '{"role":"viewer"}'::jsonb);

Copy the reviewed SQL or download a .sql file, then execute it only in the database environment you control. The converter produces text; it does not import data directly.

Prepare CSV files for reliable output

CSV is a convenient format for database seed data, but it needs consistent columns. Put field names in the first row, keep one record per line, and use quoted fields when text contains commas. A value such as "North, West" remains one cell when the CSV is properly quoted. Double quotes inside a quoted CSV field should be escaped using the CSV convention.

After loading the file, use the preview to spot shifted columns, blank headings, or rows that were copied with an extra delimiter. Empty cells are not automatically errors: choose the NULL policy that makes sense for the target table. If a value such as 0012 is an identifier rather than a number, map that column to text so leading zeroes are preserved.

Use type detection as a review step

Column detection is useful when a sheet has obvious numeric, date, or Boolean values, but it cannot know your database’s business rules. A column called status might be text even when every current value is a number. A date-like value could be a code. Inspect the samples and choose the type that matches the destination schema, not only the first few rows.

For JSON, use valid objects or arrays such as {"tier":"gold"}. A plain sentence is not JSON. For Boolean values, use the accepted forms shown by the column mapper. These small checks help the generated INSERT statements behave predictably when they reach MySQL, PostgreSQL, or SQLite.

Review the generated script before execution

Generated SQL is a starting point for your workflow, not a replacement for database safeguards. Check the table and schema names, chosen column types, primary key, empty-cell policy, and batch size. When the output includes a CREATE TABLE statement, compare it with any schema you already maintain. When it uses UPSERT mode, verify that the selected primary key is the key your database expects.

For an important import, try the script with a small sample in a development environment first. Keep backups and use the transaction, access-control, and review practices provided by your own database system. Once the output looks right, copy it into your preferred SQL client or save the downloaded file alongside the change that uses it.

Useful for seeds, fixtures, and data handoffs

Use this Excel to SQL tool to turn a product catalog, lookup table, test fixture, or analyst-maintained CSV into a reviewable SQL script. It is especially useful when a spreadsheet needs typed columns and predictable dialect formatting without a direct database connection. For production data, keep your normal review, backup, and change-management process in place.