Home › Developer Tools › Excel to SQL Converter

Excel to SQL Converter

Drop an Excel workbook or paste a range of cells and get a CREATE TABLE statement with inferred column types plus batched INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. Dates, numbers and TRUE/FALSE cells keep their real Excel types, and nothing leaves your device.

Last updated:

Sample workbook loaded
Sheet preview
Columns

Rename a column or override its detected type. Changes apply instantly to the current sheet.

CellColumn nameTypeDetectedBlankExample
Advertisement
Advertisement

How to use the Excel to SQL Converter

  1. Drop your workbook (.xlsx, .xls or .ods) or switch to the paste tab and paste a copied range.
  2. Choose the sheet and header row. Click a row number in the preview to use that row as column names.
  3. Pick the SQL dialect, table name, rows per INSERT and primary key option.
  4. Review the columns: rename them, override a detected type or skip columns you do not need.
  5. Copy or download the .sql file and run it in your database client.

How Excel cell types map to SQL

Excel cells in the columnMySQLPostgreSQLSQLiteSQL Server
Whole numbers (42, -7)INTINTEGERINTEGERINT
Whole numbers above 2,147,483,647BIGINTBIGINTINTEGERBIGINT
Numbers with decimals (19.95)DECIMAL(p,s)NUMERIC(p,s)REALDECIMAL(p,s)
TRUE / FALSEBOOLEANBOOLEANINTEGER (1/0)BIT (1/0)
Date-formatted cellsDATEDATETEXT (ISO)DATE
Date and time cellsDATETIMETIMESTAMPTEXT (ISO)DATETIME2
Time-only cells (09:30)TIMETIMETEXTTIME
Text up to 255 charactersVARCHAR(n)VARCHAR(n)TEXTNVARCHAR(n)
Longer textTEXTTEXTTEXTNVARCHAR(MAX)

For DECIMAL(p,s), p is the total number of digits and s the digits after the decimal point, both taken from the widest value in the column. Excel stores numbers as 64-bit floating point, so a value such as 0.1 + 0.2 is rounded to 15 significant digits (0.3) before it is written, the same precision Excel itself displays.

Excel dates and the 1900 date system

A date in Excel is a number: 1 is 1 January 1900 and 45,306 is 15 January 2024. The fraction is the time of day, so 45,306.5 is noon. Excel also counts a 29 February 1900 that never existed, a leftover from early spreadsheet compatibility, so serial numbers from 1 to 60 are shifted by one day. Workbooks saved with the Mac 1904 date system start counting on 1 January 1904. The converter handles all three cases and writes dates as 'YYYY-MM-DD' and date-times as 'YYYY-MM-DD HH:MM:SS', formats that MySQL, PostgreSQL, SQLite and SQL Server all parse.

Tips for a clean import

  • One header row, one table. Remove titles, notes and totals above or below the data, or set the header row number so they are skipped.
  • Merged cells only keep a value in their top-left cell; the other cells of the merge become NULL. Unmerge and fill them in Excel first if that matters.
  • Mixed columns (numbers and text in the same column) are typed as VARCHAR so no row fails to insert. Override the type in the column list if the text values are mistakes you will fix.
  • Very large sheets import faster with the database's bulk loader. Save the sheet as CSV and use LOAD DATA INFILE (MySQL), \copy (PostgreSQL), .import --csv (SQLite) or BULK INSERT (SQL Server); you can still use this page to generate the CREATE TABLE statement.
  • Wrap the script in a transaction so a single bad row rolls back the whole import instead of leaving half a table.

Frequently asked questions

How does the converter decide each column type?

It looks at every non-blank cell in the column. Whole numbers become INT (BIGINT above 2,147,483,647), numbers with decimals become DECIMAL sized to the widest value, cells formatted as dates become DATE or DATETIME, time-only cells become TIME, TRUE/FALSE cells become BOOLEAN, and everything else becomes VARCHAR sized to the longest value, or TEXT above 255 characters.

Why do my Excel dates come out as dates and not numbers?

Excel stores dates as serial numbers (days since 1 January 1900) and only the cell's number format marks them as dates. The converter reads that format and turns the serial number into an ISO date such as 2024-01-15, which every SQL dialect accepts as a date literal.

Can I convert every sheet of a workbook at once?

Yes. Tick "All sheets" and the script contains a CREATE TABLE and INSERT block for each worksheet, with table names taken from the sheet names. Column renames and type overrides apply to the sheet that is currently selected; the other sheets use the detected types.

What happens to empty cells and Excel errors?

Blank cells become NULL. Error values such as #N/A, #DIV/0! or #REF! are also written as NULL and counted in the status line so you can find and fix them in the workbook. Rows that are completely empty are skipped unless you turn that option off.

Does it keep leading zeros in codes like zip codes?

Yes, as long as Excel stored them as text (for example 02134 typed into a Text-formatted cell). Such columns stay VARCHAR so the zeros are not lost. If the cell was stored as a number, Excel already dropped the zero before the file was saved.

Are formulas converted?

The converter uses the value Excel saved with the file (the last calculated result), not the formula itself. SQL has no equivalent of a cell formula, so the computed values are what you normally want in a table.

Is my spreadsheet uploaded?

No. The workbook is opened with JavaScript inside your browser tab and the SQL is generated there too. Older .xls and .ods files need the open-source SheetJS reader, which is downloaded from a CDN the first time; your file still stays on your device.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.Excel to JSON ConverterConvert Excel sheets (XLSX, XLS, ODS) to JSON with header row, type and shape options.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.MySQL to PostgreSQL ConverterConvert MySQL dumps and CREATE TABLE statements to PostgreSQL: types, AUTO_INCREMENT, ENUMs, quotes.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.File to Base64Convert any file to a Base64 string or data URI with MIME detection, line wrap and download.HTML Table to CSVExtract any table from HTML or page source to CSV, TSV or JSON, with colspan and rowspan handled.IEEE 754 Floating Point ConverterConvert decimals to 32/64-bit IEEE 754 floats: toggle bits, see hex, exact value and rounding error.INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.IP Address ConverterConvert IPv4 to decimal, hex, binary, octal and back, with class and private/public check.ISBN Converter & ValidatorConvert ISBN-10 to ISBN-13 and back, validate check digits and hyphenate, one or in bulk.JSON Flatten / UnflattenFlatten nested JSON to dot or bracket path keys, or unflatten flat keys back to nested JSON.JSON to Dart ClassTurn JSON into Dart model classes with fromJson, toJson, null safety and nested classes.JSON to Java ClassTurn JSON into Java POJOs or records with Lombok, getters/setters and Jackson or Gson annotations.JSON to Kotlin Data ClassTurn JSON into Kotlin data classes for kotlinx.serialization, Gson, Moshi or Jackson.JSON to Markdown TableTurn a JSON array of objects into a GitHub Markdown table with column picker and alignment.JSON to PHP ArrayConvert JSON to PHP array code (short [] or array()) and PHP arrays back to JSON.JSON to Rust StructTurn JSON into Rust structs with serde derives, rename attributes, Option and Vec types.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.JSON to Swift StructTurn JSON into Swift Codable structs with CodingKeys, optionals and nested types.JSON to TOML ConverterConvert JSON to clean TOML with tables, arrays of tables, inline tables and dates.JSONL to JSON ConverterConvert JSON Lines / NDJSON to a JSON array and back, with line-level error reports.Properties to YAML ConverterConvert Java .properties to nested YAML (application.yml) and YAML back to properties.PX to EM ConverterConvert pixels to em using the parent font size, and em back to px, with conversion tables.Query String to JSONConvert URL query strings to JSON with nested brackets and arrays, and JSON back to a query string.REM to PX ConverterConvert CSS rem values to pixels for any root font size, with a quick 0.25–6rem table.SQL to JSON ConverterConvert SQL INSERT statements and dumps into a JSON array of row objects, with CSV export.TSV to CSV ConverterConvert TSV to CSV and back, or between tab, comma, semicolon and pipe, with correct quoting.TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.XML to YAML ConverterConvert XML to clean YAML with attributes, text nodes, lists and exact error lines.YAML to XML ConverterConvert YAML to pretty, well-formed XML with custom root, attributes and array item tags.Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Compare Excel FilesCompare two Excel spreadsheets cell by cell, highlight changes and export a diff report.CSV CleanerClean messy CSV in one click: trim spaces, drop empty rows and columns, fix headers, dedupe.
See all 129 Data & File Format Converters →