Skip to content
Data2026-09-13Begin5 min read

Online CSV to SQL Tool: Import Tabular Data into Databases

What is CSV to SQL

Turn a CSV table into paste-ready INSERT statements for seeding a dev database, documenting examples, or one-off small moves. Try CSV to SQL — the same input can also emit a Markdown or HTML table.

Example matching this site's MySQL-style output

CSV:

id,name,email,age
1,Alice,alice@example.com,28
2,Bob,bob@example.com,32

SQL (backtick identifiers; every non-empty value is a quoted string — numbers are not bare):

INSERT INTO `users` (`id`, `name`, `email`, `age`) VALUES
  ('1', 'Alice', 'alice@example.com', '28'),
  ('2', 'Bob', 'bob@example.com', '32');

Switch the dialect control to PostgreSQL and identifiers become "users" / "id" instead. If you need true integer columns, load into a staging table and INSERT ... SELECT CAST(...) — the converter does not invent types.

Why this step still exists

  1. Dev seed data — tens to hundreds of rows; hand-writing INSERT is slow
  2. Docs / README samples — Markdown table mode pastes into documentation
  3. Pre-integration fixtures — pair with CSV/JSON from API samples
  4. Not million-row production ETL — use COPY / LOAD DATA / a real pipeline

How to use (real UI)

  1. Paste CSV (header on the first row)
  2. Choose output: SQL INSERT / Markdown Table / HTML Table
  3. In SQL mode, set the table name (default my_table) and identifier style (MySQL backticks or PostgreSQL double quotes)
  4. Convert and copy

Delimiter: the parser accepts a custom delimiter argument, but the UI currently fixes comma. Normalize semicolon CSV via CSV/TSV first.

Implementer's notes (parseCSV / csvToSQL)

Parsing

  • Quoted fields, "" escapes, and newlines inside quotes are supported
  • Headers are trimmed; blank lines skipped
  • A leading UTF-8 BOM is stripped before parse (Excel-exported CSV no longer poisons the first header as id)
  • Short rows pad missing columns with empty strings (more lenient than the bidirectional CSV/JSON tool, which throws on width mismatch)
  • The literal text null / NULL is not treated as SQL NULL — only an empty cell becomes NULL

SQL emission

  • Identifiers: MySQL style doubles internal backticks; PostgreSQL style doubles internal "
  • Values: empty → NULL; otherwise '...' with ' → ''
  • No bare numbers, no boolean detection, no date parsing
  • One multi-row INSERT ... VALUES (...), (...);

Markdown / HTML

  • Markdown escapes | inside cells as \| so pipes do not break the table
  • HTML entity-escapes & < > " for safe static previews

Excel quirks that remain outside the converter

  • Date serials and dropped leading zeros are export-time problems — re-export those columns as text
  • European semicolon CSV still needs a delimiter pass first

Large-file boundary

  • Building a giant SQL string in a tab will stutter; fine for demos, not for tens of thousands of rows
  • No transactions, no ON CONFLICT, no batch-size control — wrap and key the import yourself for idempotent reruns

RFC 4180's four edges (read side)

  1. Comma inside a field → must quote
  2. Quote inside a field → double it (""), not backslash
  3. Newline inside quotes → legal; wc -l disagrees with logical rows
  4. UTF-8 BOM → stripped at parse start here; still strip before COPY/LOAD elsewhere

INSERT vs COPY / LOAD

PathUse whenNotes
Batched INSERT hereSmall tables, demos, docsChoose MySQL or PostgreSQL quoting
PostgreSQL COPY ... CSV HEADERLarge filesFast; watch encoding
MySQL LOAD DATALarge filesPath + LOCAL security trade-offs
SQLiteMulti-INSERT in a transactionNo native CSV bulk (extensions aside)

Production pattern: TEXT staging → visible CAST / :: → final table. Keep type decisions in reviewable SQL, not converter magic.

Excel dialect and repeatable imports

  1. Separator: some locales export ; — normalize with CSV/TSV
  2. Leading zeros / dates: set columns to text in the spreadsheet before export
  3. Idempotent reruns: this tool does not emit ON CONFLICT / REPLACE — DELETE/TRUNCATE demo tables, or wrap your own upsert

Treat CSV→SQL as visible scaffolding. Leave types and conflict policy in SQL you can review.

StepTool
Tables ↔ objectsCSV/JSON, JSON→CSV
SeparatorsCSV/TSV
INSERT layoutSQL formatter
Config side pathYAML↔JSON
PostsCSV/JSON, JSON/CSV, SQL formatter

FAQ

Newlines inside fields?

Wrap the field in double quotes. The parser tracks quote state; it does not only split on physical lines.

Why are numbers quoted?

Everything inserts as text so 00123 stays intact. Cast in SQL after load.

Does the string null become SQL NULL?

No. Only empty cells → NULL. Intentional, so the legitimate text null is not eaten.

PostgreSQL syntax errors?

Pick PostgreSQL in the dialect control, or manually change `col` to "col". String escaping with '' is shared.

Slow bulk import?

Use this tool for small sets; use COPY/LOAD DATA for bulk, optionally defer non-critical indexes and commit in batches.

Transactions and review before you paste

Generated INSERTs are easy to run twice by accident. Wrap a seed block in BEGIN / ROLLBACK while you spot-check row counts, then COMMIT only after SELECT COUNT(*) looks right. Prefer a disposable schema or table suffix (_seed) on shared dev databases. The SQL formatter helps reviewers scan wide INSERT lists; it does not validate types — keep CAST / :: in hand-written follow-up SQL.

Identifiers vs string literals

MySQL backticks and PostgreSQL double quotes protect identifiers (column names with spaces or reserved words). They are not string quotes — values still use single quotes with '' escaping. Mixing the two ("hello" as a value in PostgreSQL) creates a column reference and a confusing “missing column” error that looks unrelated to CSV. Pick the dialect control on CSV to SQL before copying.


From ToolVault. Related: CSV→SQL, CSV/JSON, SQL formatter, CSV/TSV. More on the homepage.