JSON to SQL converter

Paste a JSON array of objects, such as an API response or an export, and get SQL that creates a table and loads the rows. Column types are chosen from the values, and quoting follows the dialect you pick.

Rows: 3, columns: 6.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Paste a JSON array of objects. One object on its own also works and gives one row.
  2. Enter the table name (schema.table is fine) and pick MySQL, PostgreSQL or SQLite.
  3. Choose whether you need CREATE TABLE, INSERT statements or both, and how many rows go in each INSERT.
  4. Copy the SQL and run it in your database client.

How it works

Columns are all keys found in the objects, in the order they first appear. Each column’s type comes from its values, and a key that is missing in an object gives NULL in that row. Rows are written as multi-row INSERT statements, which all three databases support; big arrays are split by the Rows per INSERT setting.

Numbers are written as they are, booleans as TRUE/FALSE (1/0 in SQLite), and a column of mixed values gets every value as quoted text, so the INSERT matches its TEXT type.

Worked example

[{"id":1,"name":"Ann","tags":["a"]},{"id":2,"name":"Bob"}] with the table users in PostgreSQL gives:

CREATE TABLE "users" (
  "id" BIGINT NOT NULL,
  "name" TEXT NOT NULL,
  "tags" JSONB
);

INSERT INTO "users" ("id", "name", "tags") VALUES
  (1, 'Ann', '["a"]'),
  (2, 'Bob', NULL);

tags is missing from Bob’s object, so the column allows NULL and his row gets NULL.

Tips

  • Add a PRIMARY KEY and indexes yourself: the generator cannot know which column is the key.
  • Dates in JSON are strings, so they become TEXT; change the type to DATE or TIMESTAMP if the values are ISO dates.
  • Integers above 9,007,199,254,740,991 lose precision when JSON is read in JavaScript; keep big IDs as strings in the JSON.
  • For CSV data use CSV to SQL INSERT.

Frequently asked questions

How are column types chosen?

From the non-null values of each key: only whole numbers → BIGINT (INTEGER in SQLite); any fraction → DOUBLE, DOUBLE PRECISION or REAL; true/false → BOOLEAN (INTEGER 1/0 in SQLite); strings → TEXT, or VARCHAR(255) in MySQL when no value is longer; objects and arrays → JSON, JSONB or TEXT. A key holding different kinds of values becomes TEXT.

When is a column NOT NULL?

When every object has the key with a non-null value. A key that is missing from some objects or is null somewhere gives a nullable column, and those rows get NULL.

How are strings escaped?

Strings are put in single quotes and a quote inside is doubled: O'Neil becomes 'O''Neil'. For MySQL backslashes are doubled too, because MySQL reads them as escapes. Table and column names are quoted with backticks in MySQL and double quotes in PostgreSQL and SQLite.

What happens to nested objects and arrays?

They are stored as JSON text in one column: JSON in MySQL, JSONB in PostgreSQL, TEXT in SQLite (whose JSON functions read text). The generator does not split them into separate tables.

Is my data uploaded?

No. The SQL is built by JavaScript in your browser.

More in Developer

All tools in this category: Developer ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.