---
title: "CSV to SQL Converter - Generate INSERT Scripts"
description: "Convert CSV to SQL INSERT statements for PostgreSQL, MySQL or SQLite. Preserve IDs, control NULLs, review column types and download SQL in your browser."
url: https://candoya.com/tools/csv-to-sql/
locale: en
type: browser-tool
---

# CSV to SQL Converter

Category: [Developer](https://candoya.com/tools/dev/)

## How do I convert CSV to SQL?

Paste CSV or open a UTF-8 file, choose PostgreSQL, MySQL or SQLite, and generate a SQL script. This CSV to SQL converter writes quoted CREATE TABLE and INSERT statements on your device. Columns stay text by default, preserving leading-zero IDs and exact decimal strings until you choose to infer types.

## Preserve values before choosing types

CSV stores fields, not a database schema. The default keeps every value as text, including dates, decimals and the word NULL. Optional inference scans the entire column and accepts only unquoted signed 64-bit integers or lowercase true/false. A quoted numeric value, leading zero, decimal or out-of-range integer keeps that whole column as text. Review the result against your target schema.

## Empty strings and SQL NULL are different

By default, an empty CSV cell becomes an empty SQL string. The NULL option changes only unquoted empty cells. A quoted empty field stays an empty string, and spaces are never trimmed. Blank physical records are skipped. Ragged rows, duplicate headers and malformed quoting stop conversion instead of silently dropping values.

## How to use it

1. **Add your CSV** - Paste CSV, open a local CSV or TSV file, or load the example. The first row supplies column names by default.
2. **Choose the SQL output** - Choose your SQL dialect and table name. Open CSV and SQL options to change delimiters, batching, type inference or empty-cell handling.
3. **Generate and review** - Select Generate SQL. Review the output and column types, then copy the complete script or download the .sql file.
4. **Run in your database client** - Run the reviewed script in your own database client using a UTF-8 connection. This page never connects to a database.

## Who it's for

- Create a small development seed dataset from a spreadsheet export.
- Preserve postal codes and customer IDs such as 00123 as database text.
- Prepare INSERT statements for an existing table without adding CREATE TABLE.
- Compare generated scripts for PostgreSQL, MySQL and SQLite before importing.

## Expert note

MySQL backslashes depend on SQL mode. For strings containing backslashes or control characters, this converter emits UTF-8 hexadecimal expressions with CONVERT(... USING utf8mb4), so those values survive both ordinary mode and NO_BACKSLASH_ESCAPES. PostgreSQL uses explicit E string literals; SQLite keeps backslashes literal.

## Frequently asked questions

### Is my CSV uploaded to a server?

No. File reading, CSV parsing and SQL generation run in your browser. The converter does not send your dataset to a server or connect to a database. Copy and download use the script generated on your device.

### Is this CSV to SQL converter free?

Yes. You can paste data, open files and download SQL without an account or payment. There is no database connection to configure. You need your own database client to execute the generated script after reviewing it.

### What are the file and row limits?

Input is limited to 2 MiB of UTF-8 text, 10,000 data rows, 100 columns and 200,000 total cells including headers. Generated SQL is capped at 12 MiB. Larger imports are better handled with a database bulk loader. The on-page preview is shortened after 60,000 characters; exports remain complete.

### Can I generate SQL for MySQL, PostgreSQL and SQLite?

Yes. Each dialect gets its own identifier quoting, string handling and column types. Text maps to LONGTEXT with utf8mb4 in MySQL and TEXT elsewhere. Inferred integers use BIGINT in PostgreSQL and MySQL, or INTEGER in SQLite. Inferred SQLite booleans use integer 1 and 0.

### Will leading zeros and large numbers be preserved?

Yes, in the default text mode. Optional inference also leaves leading-zero values, decimals and integers outside the signed 64-bit range as text. Integer conversion uses the original decimal digits rather than JavaScript floating-point numbers. Existing table types can still coerce values when you run the script.

### How do I handle CSV without a header?

Turn off First row contains column names. The converter creates column_1, column_2 and so on, and treats the first record as data. With headers enabled, names are kept exactly and quoted. Blank, duplicate, overly long or unsupported names must be corrected before export.

### Does this tool create a SQLite database file?

No. It downloads a UTF-8 .sql text script, not a database file. Execute that script using SQLite or your chosen database client. The tool does not infer decimal precision, dates, primary keys, indexes or relationships, and it does not check an existing database schema.

## Related tools

- [CSV Viewer](https://candoya.com/tools/csv-viewer/)
- [CSV Editor](https://candoya.com/tools/csv-editor/)
- [SQL Playground](https://candoya.com/tools/sql-playground/)
- [CSV to JSON Converter](https://candoya.com/tools/csv-to-json/)
- [SQL Formatter](https://candoya.com/tools/sql-formatter/)

---

*Markdown edition of <https://candoya.com/tools/csv-to-sql/>, published for AI agents and other automated readers. Index of key pages: <https://candoya.com/llms.txt>.*
