CSV to SQL
Convert CSV to SQLite, PostgreSQL or MySQL INSERT scripts while preserving IDs as text.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Generate SQLite, PostgreSQL or MySQL INSERT scripts locally with explicit quoting and text values that preserve leading-zero and long identifiers.
How to use it
- 1Load CSV and select the destination SQL dialect and table name.
- 2Choose whether to create a text-only table and convert empty fields to NULL.
- 3Generate, review and download SQL; test separately before execution.
Example
- Input
- id 001 SQLite; table records; creation off
- Output
- INSERT INTO "records" ("id") VALUES ('001');
The full download also includes two explanatory comment lines.
What happens to your data
SQL generation is local and never connects to a database or executes statements. Downloads contain source values; review and protect them as carefully as the original CSV.
Last updated October 2026
Convert a CSV into a reviewable SQL script for SQLite, PostgreSQL or MySQL. Generate one INSERT statement per data row and optionally create a table with text columns. Leading-zero IDs, large integers and date-like strings remain text rather than being guessed into database types.
The tool generates a file only. It does not connect to a database, run SQL, overwrite a table or request credentials. Review the script and try it in a disposable database before using a production system.
How it works
Choose the input delimiter, database dialect and destination table name. Include CREATE TABLE creates TEXT columns for SQLite and PostgreSQL, or LONGTEXT columns with utf8mb4 table character set for MySQL. Creation is intentionally not IF NOT EXISTS: an existing table should cause a visible database error, not silently reuse an incompatible schema. You can disable creation to target an existing table, but that table's column types, constraints, triggers and server settings may coerce or reject values.
Headers become quoted column identifiers in source order. Names are limited to 63 UTF-8 bytes, must be nonempty and cannot contain control characters. Embedded identifier quote characters are doubled. A table name such as app.records is treated as one quoted name containing a dot, not a schema and table pair. Schema-qualified targets and custom SQL types are not supported. SQLite/MySQL headers that collide ignoring case are rejected; PostgreSQL quoted names remain case-sensitive. Use CSV Column Editor first to resolve names.
Every value is exported as text by default, including 001, 9007199254740993, TRUE and NULL. Empty fields become empty strings unless Convert empty fields to SQL NULL is enabled; this explicit option is lossy because the original empty string then becomes a database null. The literal word NULL always remains text. No dates, booleans, decimals or keys are inferred.
SQLite string literals double apostrophes. PostgreSQL uses explicit E strings, doubling apostrophes and escaping backslashes. MySQL uses UTF-8 hexadecimal text expressions with CONVERT(... USING utf8mb4), avoiding dependence on backslash string modes. NUL characters and unpaired Unicode surrogates are rejected rather than silently altered. Your SQL client and database must still use suitable UTF-8 settings; this is not a guarantee for every server version, collation or import interface.
One INSERT per row keeps the script reviewable and avoids a single giant VALUES list. There is no automatic transaction wrapper, rollback, migration, DROP, DELETE or UPSERT. A runtime error may leave earlier statements applied depending on how your database client executes the script. Test first, use backups and choose an appropriate transaction strategy yourself. An exported script contains the CSV's data and must be handled as sensitive when the source is sensitive.
Load a UTF-8 CSV or paste text, then choose comma, semicolon or tab explicitly. Inputs are limited to 2 MiB, 10,000 records including the required header, 200 columns and 200,000 cells. Headers must be nonempty and exactly unique. Malformed quotes, unequal field counts and invalid UTF-8 files are rejected, not silently repaired. Quoted commas, escaped quotes and multiline fields stay in their original cells. Output is capped at 10 MiB; exceeding a limit produces an error rather than a partial download. Header-only input produces optional table creation with zero INSERT statements. Repeating many long identifiers in INSERT statements can reach the output budget before the input limit; use CSV Split or CSV Sample to reduce the export. Preview displays the first 100,000 characters and the download contains the complete successful script.
Processing stays in browser memory; the tool does not upload cell contents or connect to your database. Editing the source removes previous results, and a late file read cannot overwrite a newer edit. Changing output options also clears an old result. Downloads can contain confidential data and remain your responsibility.
Worked example: Keep leading zeros and escape an apostrophe
- Input
- id,name 001,O'Brien SQLite; table imported_data; CREATE TABLE enabled
- Result
- -- Toolvore CSV to SQL: sqlite; text values; review before execution. -- No SQL is executed by this tool. Run only in your intended test database. CREATE TABLE "imported_data" ( "id" TEXT, "name" TEXT ); INSERT INTO "imported_data" ("id", "name") VALUES ('001', 'O''Brien');
The ID remains quoted text. No statement is executed by the converter.
Common use cases
- Creating a local SQLite test fixture from a small CSV
- Preparing a PostgreSQL staging-table import with text-preserved IDs
- Generating mode-independent MySQL text literals for review
- Inspecting an import script before any database credentials are involved
Frequently asked questions
Does this import directly into my database?+
No. It only downloads SQL text. No credentials, database connection or query execution is involved.
Why are all columns text?+
Automatic inference can destroy leading zeros, round IDs or reinterpret dates. Text is a deliberate staging format. You can design and validate a typed schema later using your database tools.
Will a cell containing NULL become a null value?+
No. The literal word NULL remains text. Only a truly empty field becomes SQL NULL when that option is explicitly enabled.
Why does MySQL output contain hexadecimal expressions?+
The UTF-8 bytes are represented as hex and explicitly converted to utf8mb4 text. This avoids confusing backslash escape modes; it is encoding, not encryption.
Which table and column names are supported?+
Names must be nonempty, valid Unicode, at most 63 UTF-8 bytes and free of control characters. SQLite destination names beginning sqlite_ are reserved and rejected. MySQL also rejects names ending in a space or containing supplementary-plane characters such as emoji. Rename incompatible headers with CSV Column Editor before exporting.
Can I run this safely on an existing production table?+
Review and test it first. Existing types, constraints and triggers can change the outcome, and a partial execution can leave some rows imported. This converter provides neither a migration plan nor a production rollback guarantee.
Related tools
CSV Column Editor
Keep, reorder and rename CSV columns without changing cell values or row order.
CSV Validator
Check CSV syntax, row widths and headings without silently repairing data. Download a diagnostic report.
CSV Data Profile
Inspect CSV column counts, empties, distinct values and duplicate rows locally; export a JSON profile.
CSV Splitter
Split CSV records into smaller files, preserve quoted line breaks and download a ZIP locally.