JSON to SQL
Turn JSON data into SQL INSERT statements: columns are unioned automatically, CREATE TABLE is optional, and identifier quoting plus string escaping follow MySQL, PostgreSQL or SQLite rules.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Conversion settings
Columns are the union of every object; single quotes are doubled and MySQL backslashes are escaped; objects and arrays become JSON strings.
Result
What this tool does
- Turn an API response or a small JSON export into ready-to-run INSERT statements instead of hand-writing column names and escapes.
- Seed a new table from irregular data: columns are the union of every object, missing keys become NULL, so rows do not have to line up first.
- Tick "Include CREATE TABLE" to get runnable DDL plus DML; types (INT, DOUBLE, TINYINT(1), JSON, TEXT) are inferred from the values.
- Move scripts between MySQL, PostgreSQL and SQLite with the dialect switch, which controls identifier quoting and string escaping.
Example
Input
[{"id":1,"name":"O'Brien","active":true},{"id":2,"name":"Ada","active":false}]Output
INSERT INTO `users` (`id`, `name`, `active`) VALUES (1, 'O''Brien', TRUE), (2, 'Ada', FALSE);
MySQL dialect quotes identifiers with backticks; single quotes are doubled as the SQL standard requires, and backslashes are escaped as well.
Frequently asked questions
What if the objects in the array have different keys?
The column list is the union of all objects in order of first appearance. A row without that key writes NULL (or DEFAULT if you turn off "Write NULL for missing fields"). Extra keys are never dropped, they are just appended.
How are quotes and backslashes inside strings escaped?
Single quotes are always doubled, which every dialect accepts. Backslashes are doubled only for MySQL, where a backslash starts an escape sequence by default; PostgreSQL runs with standard_conforming_strings on and SQLite does not treat backslashes specially, so they stay untouched.
How do nested objects and arrays end up in the database?
They are serialized to a JSON string and wrapped in single quotes. MySQL JSON columns and PostgreSQL JSONB columns accept that literal directly, and a TEXT column simply stores the JSON text.
Can the generated INSERT hold many rows at once?
Yes: by default all rows are merged into one INSERT ... VALUES (...), (...) statement, which every database supports and executes fastest. Untick the option to emit one statement per row when you want to run them in batches.
Why did the dots in my table name get split?
A dotted table name is treated as schema.table and each part is quoted separately, so public.users becomes "public"."users". Dots inside column names are not split; the whole name is quoted as one identifier.
Keywords:json to sqlinsert statementsql generatorcreate tablemysqlpostgresqlsqliteJSON转SQL生成 INSERT建表语句数据导入