SQL INSERT to JSON Converter
Paste one or more INSERT INTO statements from a dump or a migration and get an array of JSON objects with the column names as keys.
Questo contenuto è in inglese.
Esempi svolti
One row
INSERT INTO t (id, name) VALUES (1, 'Ann');
[ { "id": 1, "name": "Ann" } ]
A single table gives an array of objects.
Quotes and NULL
INSERT INTO t (id, note) VALUES (2, 'It''s fine'), (3, NULL);
[ { "id": 2, "note": "It's fine" }, { "id": 3, "note": null } ]
The doubled quote becomes one apostrophe and NULL becomes null.
Informazioni su SQL INSERT to JSON Converter
This converter reads SQL INSERT statements and gives you JSON. Paste rows from a database dump, a migration or a seed file and each row becomes an object, with the column names as keys.
Multi-row inserts, quoted strings with escaped quotes, numbers, NULL, TRUE and FALSE are all understood, and comments are ignored. A dump that inserts into several tables gives one object with an array for each table.
Come usare SQL INSERT to JSON Converter
- Paste your INSERT statements, or open a .sql file.
- Choose the indent size, and whether a single table should be an array or an object named by table.
- Copy the JSON or download it as a file.
Usi comuni
- Turning seed data into JSON fixtures for tests
- Moving a few rows from a database into an API mock
- Checking what a dump file really contains
- Converting data for a tool that only reads JSON
Domande frequenti
Which statements are read?
INSERT INTO ... VALUES statements, with or without a column list and with one or many rows. CREATE TABLE, UPDATE and other statements are skipped.
What if there is no column list?
Keys are named column_1, column_2 and so on, in the order the values appear.
How are values converted?
Quoted values stay as strings, plain numbers become numbers, NULL becomes null, and TRUE and FALSE become true and false. Anything else, such as a function call, is kept as text.
Why did I get an error about a row?
A row had a different number of values from the number of columns named. The message names the table so you can find the row.