Skip to content
Jellykit

JSON to SQL Converter

Turn an array of JSON objects into SQL INSERT statements, with an optional CREATE TABLE, for five common databases.

  • Runs on your device
Loading tool

About JSON to SQL Converter

Seeding a test database, moving an API export into a table or sharing a fixture with someone who lives in SQL means writing INSERT statements by hand. Paste an array of JSON objects and each object becomes a row: every key that appears in any object becomes a column, and a missing key becomes NULL.

Pick PostgreSQL, MySQL or MariaDB, SQLite, SQL Server or standard SQL, and names and strings are quoted the way that database expects, so apostrophes, reserved words and odd characters cannot break the script. Column types for CREATE TABLE are inferred from the values; check them before you run it against real data.

How it works

  1. The JSON is read by a strict parser that keeps numbers exactly as written, so a 20-digit id is inserted with all its digits.
  2. Columns are collected from every object in order of first appearance. Whole numbers become INTEGER or BIGINT (or an exact NUMERIC when larger), other numbers floating point, true and false BOOLEAN or BIT, and nested objects and arrays JSON text. A column with mixed kinds of value becomes text.
  3. Identifiers are always quoted, and string values are written as literals with quotes doubled (and, for MySQL, backslashes escaped), so a value such as O’Neil or a stray semicolon stays data.

Questions

Is the output safe to run against my database?

The quoting means values cannot escape their literals, but always read the script first: the inferred column types are a best guess from the sample you pasted, and CREATE TABLE fails if the table already exists.

How are nested objects and arrays stored?

As compact JSON text in a single column. PostgreSQL gets a JSONB column and MySQL a JSON column; SQLite and SQL Server store it as text. To spread nested values over columns instead, flatten the JSON first.

Why does a money column come out as floating point?

A number with a fraction such as 12.50 is typed as floating point because that suits most data. For amounts that must stay exact, change the type to DECIMAL with the precision you need before running the script. The values themselves are written exactly as in your JSON.

How many rows can it convert?

Up to 5 MB of JSON, typically tens of thousands of rows. Choose 100 or 1,000 rows per INSERT for much faster loading; SQL Server accepts at most 1,000 rows in one statement.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.