JSON to SQL Converter
Generate CREATE TABLE and INSERT statements from JSON.
JSON
SQL
About the JSON to SQL converter
Paste an array of JSON objects and get SQL you can run: an optional CREATE TABLE with inferred column types, followed by INSERT statements for every record.
It is built for seeding a development database or loading a fixture, not for migrating production data.
Type inference
Column types are guessed from the values present. All-integer columns become INTEGER, mixed numerics become DECIMAL or REAL, booleans become BOOLEAN, and everything else becomes VARCHAR sized to the longest value — or TEXT when that would be over 255 characters.
Nested objects and arrays are serialised as JSON strings, which is usually what you want for a JSON or JSONB column.
Quoting and escaping
Identifiers are quoted with double quotes for PostgreSQL and SQLite and backticks for MySQL, so reserved words and mixed-case names work. Single quotes inside string values are doubled, the standard SQL escape.
That said: generated SQL should still be read before it is run. Review the types, add your primary keys and indexes, and never point it at a table you cannot recreate.
Batched or individual inserts
A single multi-row INSERT is dramatically faster and is the default. Individual statements are easier to diff and to run selectively when one row fails, so switch when you are debugging.
Frequently asked questions
Are the statements safe to run directly?
Treat them as a draft. Values are escaped correctly, but the schema is inferred from a sample — check the column types and constraints before running anything against a real database.
How do I get a primary key?
Add it by hand to the CREATE TABLE. Inferring which column is the key from data alone is guesswork we would rather not do on your behalf.
What about NULL versus empty string?
JSON null becomes SQL NULL. An empty JSON string becomes an empty string literal. The distinction is preserved.