SQL to JSON
Converts SQL INSERT statements into JSON records, pairing each named column with its value. Numbers, quoted strings, NULL, TRUE, and FALSE are mapped to their JSON equivalents, and surrounding statements and comments are ignored. Inserts into a single table produce an array; inserts into several tables produce an object keyed by table name. Runs entirely in your browser — nothing is sent to a server.
Converts SQL INSERT statements into JSON records, pairing each named column with its value. Numbers, quoted strings, NULL, TRUE, and FALSE are mapped to their JSON equivalents, and surrounding statements and comments are ignored. Inserts into a single table produce an array; inserts into several tables produce an object keyed by table name. Runs entirely in your browser — nothing is sent to a server.
Use cases
- Turning a SQL seed file into JSON test fixtures
- Migrating seed data into a document database
Examples
Two-row insert
INSERT INTO users (id, name) VALUES (1, 'Ada'), (2, 'Linus');
[
{
"id": 1,
"name": "Ada"
},
{
"id": 2,
"name": "Linus"
}
]FAQ
Is my data sent to a server?
No — this tool runs entirely in your browser.
Why does my INSERT fail to convert?
The column list is required, because without it the column names are unknown. Values must also be literals — an expression such as NOW() is reported rather than guessed at.
What about SELECT statements?
Only INSERT statements carry data, so they are the only kind converted. Other statements in the same input are ignored.