Getting Data Out of a Dump File
By toolbelt maintainers ·
Updated
The only copy of your data is INSERT statements. Here is how to read them back into something you can work with.
What is this tool?
A SQL dump stores rows as INSERT statements. Converting to JSON means turning those value tuples back into objects.
How it works
I find the column list and the tuples, then walk the tuple body tracking quote state and bracket depth, so a comma inside a string does not split a column. Doubled single quotes — the SQL escape for an apostrophe — are turned back into one.
Example
INSERT INTO users (id, name) VALUES (1, 'Ada'), (2, 'O''Brien');
becomes
[{"id":1,"name":"Ada"},{"id":2,"name":"O'Brien"}]When to use it
Recovering data when no export tool exists. Turning a fixture written as SQL into JSON your tests can read. Checking what a migration actually inserted.
Optimization Tips
Dates will arrive as strings, because that is how SQL dumps quote them. Convert them deliberately rather than assuming the type survived. And convert one table at a time — the tool reads one statement.
Frequently Asked Questions
Are escaped quotes handled?
Why are dates strings?
Does it run against a database?
Multiple statements?
Related tools
- CSV to JSONConvert CSV data to a JSON array of objects. Automatically maps the first row to object keys, perfect for importing spreadsheet data into web applications or APIs.
- JSON to CSVConvert a JSON array into a clean CSV file. Extract unique keys to form the header row, perfect for exporting API data for analysis in Excel or Google Sheets.
- XML to JSONConvert XML documents to JSON objects. Bridge the gap between legacy SOAP APIs and modern frontend applications while preserving attributes and hierarchical data.
- JSON to XMLConvert JSON objects to valid XML markup. Automatically handle arrays, attributes, and special characters, making it easy to integrate with older enterprise systems.