Converting MySQL INSERT Dumps to JSON for APIs, Tests, and Seed Data
Sometimes You Just Have a Dump File
A colleague sends you a .sql file with a handful of INSERT INTO statements. You don't want to install a database, import the dump, and query it just to see three rows of sample data. You want the data as JSON, right now.
What This Actually Requires
Parsing a MySQL INSERT statement correctly means handling:
- Column lists declared once, then reused across every row: INSERT INTO products (id, name, price) VALUES (...), (...), (...).
- Quoted strings that may contain escaped quotes or commas, such as O'Brien or "Product, Deluxe Edition".
- Mixed types: numbers and booleans should come out as real JSON numbers and booleans, not strings, and NULL should become JSON null.
- Multiple value tuples in a single statement, each becoming one JSON object.
A Typical Use Case
- You receive a small seed or fixture dump like an INSERT INTO products statement with a handful of value rows.
- Paste it into the MySQL to JSON Dumper.
- Get back a clean JSON array, ready to paste into a test fixture, a mock API response, or a frontend prototype.
Why Not Just Spin Up a Database?
For a three-row sample, standing up MySQL, importing a dump, and running a SELECT query is a lot of ceremony for very little payoff. Parsing the INSERT statement directly gets you the same data in one step, entirely client-side, with no credentials, no server, and no risk of accidentally pointing a real dump at a shared database.
Once you have the JSON, the JSON Formatter & Validator is a natural next stop for pretty-printing or validating the result before it goes into your codebase.