CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

SQL INSERT ⇄ CSV / JSON Converter

Turn SQL INSERT statements into CSV or JSON, and generate INSERTs from CSV or JSON - multi-row VALUES, quote escaping, and NULLs handled, nothing uploaded.

Overview

Converts SQL INSERT statements into CSV or JSON, and generates INSERT statements from CSV or JSON, in both directions, entirely in your browser. Multi-row VALUES, doubled-quote and backslash string escapes, NULL literals, and quoted identifiers are all handled - so a database dump, an export script, and a spreadsheet can speak the same dialect for an afternoon.

How It Works

Choose the direction. In the SQL-to-data direction, paste your INSERT statements and switch between JSON output (typed records: numbers as numbers, NULL as null) and CSV. In the data-to-SQL direction, paste CSV or JSON records, name the target table, and the INSERT statements appear with smart typing - unquoted numbers, TRUE/FALSE booleans, and bare NULLs where the value calls for them.

Step-by-Step Usage Guide

  1. Paste a database dump or export script to convert SQL into data, or paste CSV/JSON to convert data into SQL.
  2. For data-to-SQL, set the target table name and toggle smart types to match your schema.
  3. Copy the output, or fix the highlighted warning when a statement was skipped.
  4. Verify a round trip on a small sample before running generated statements against a real database.

Technical Specifications & Standards

The SQL parser is a real tokenizer, not a regex over the whole statement: it walks each VALUES tuple character by character, tracking string state so that commas inside quotes do not split values and doubled quotes ('') or backslash escapes (\', \n, \\ ...) do not terminate strings early. Statements whose table or column list differ from the first are skipped with a visible warning instead of producing silently misaligned rows. On the generation side, every value is escaped by doubling single quotes - the one convention that is simultaneously valid in standard SQL, MySQL, and PostgreSQL - and identifiers that are not plain names are quoted with double quotes per the SQL standard. Smart typing is deliberately conservative: only values matching a strict integer-or-decimal pattern lose their quotes, because '0123' unquoted would silently become the number 12 in most engines.

Targeted Use Cases

  • Turning a mysqldump-style INSERT dump into CSV for a spreadsheet review.
  • Seeding a development database from CSV data the client sent over.
  • Converting JSON API fixtures into INSERT scripts for a test database.
  • Extracting just the rows of one table from a large multi-statement dump.

Notes & Gotchas

  • Run generated INSERTs inside a transaction so a bad row costs you a rollback, not a half-populated table.
  • Check the smart-types toggle against your schema: an all-numeric postcode or phone number should be quoted.
  • One table and one column list per conversion keeps the mapping unambiguous - split mixed dumps first.
  • Round-trip a sample (SQL to CSV back to SQL) and diff it against the original before trusting a big conversion.

Frequently Asked Questions

Which SQL dialects does this understand?

The common core: standard INSERT ... VALUES syntax with optional column lists, doubled-quote and backslash string escapes, and NULL literals. Engine-specific syntax such as ON DUPLICATE KEY clauses is ignored gracefully; the VALUES themselves still convert.

Why is my numeric-looking value quoted?

Smart typing only unquotes values that match a strict number pattern without leading-zero ambiguity. Values like postal codes or phone numbers stay quoted so a database does not silently strip their leading zeros.

What happens to NULL values?

SQL NULL becomes JSON null, and an empty CSV cell. On the way back, JSON null and a bare 'NULL' string become SQL NULL; the CSV-to-SQL path also treats an empty cell as NULL when smart types are on.

Does my data leave the browser?

No. Parsing and generation run entirely in your page. That matters for dumps: real INSERT files contain customer data, and this tool never uploads a byte of it.