JSON ↔ SQL Converter
Runs locally in your browserTurn JSON into CREATE TABLE and INSERT statements, or SQL INSERT data into JSON
More options
1–1000 rows. SQL Server accepts at most 1000 rows in one VALUES list.
When off, only reserved words and names with special characters are quoted.
JSON input
Related Tools
What JSON ↔ SQL does
JSON ↔ SQL turns JSON records into CREATE TABLE and batched INSERT statements for PostgreSQL, MySQL, SQLite and SQL Server, and turns SQL INSERT data back into JSON. Columns are the union of keys across every record, so a key that appears in only one object still gets a column, and missing keys are written as NULL. When the JSON holds several arrays, the dataset selector shows each JSONPath with its row count so you can choose the one to convert.
How to use
- 1.Choose JSON → SQL or SQL → JSON and the SQL dialect.
- 2.Paste data, upload or drop a .json or .sql file, or load an example.
- 3.For JSON → SQL, set the table name and the statements to generate; More options holds rows per INSERT and identifier quoting.
- 4.Review the output, the notes and the review guidance below it.
- 5.Copy the result, download data.sql or data.json, or open it in the other direction to check a round trip.
Type mapping and escaping
Types are inferred conservatively from the values. Whole numbers become INTEGER, then BIGINT or an exact NUMERIC/DECIMAL when they grow larger; decimals become NUMERIC in PostgreSQL, DOUBLE in MySQL, REAL in SQLite and FLOAT in SQL Server; ISO 8601 dates and timestamps become date and timestamp types; strings that only look like numbers stay text. Nested objects and arrays use JSONB in PostgreSQL and JSON in MySQL, and are stored as serialized JSON text in SQLite and SQL Server. Apostrophes are doubled in every dialect, MySQL also escapes backslashes, SQL Server strings use N'…' Unicode literals, and booleans are written as TRUE/FALSE or 1/0 as each dialect expects. Large integers and long decimals keep their exact digits.
SQL → JSON scope, limits and privacy
SQL → JSON reads INSERT … VALUES statements with node-sql-parser: single and multi-row inserts, several statements and several tables, which are returned as an object keyed by table name. A CREATE TABLE in the same input supplies column names, turns JSON columns into nested JSON and BOOLEAN or BIT columns into true and false. SELECT, UPDATE, functions such as NOW(), expressions and DEFAULT are rejected with a message instead of being guessed. SQL is parsed, never executed, and your data is never sent to a server; the parser for the chosen dialect is downloaded once, the first time you convert. Generated SQL is meant for inspection, migrations and development: review it before running it on production data, and use parameterized queries in applications.
