JSON to SQL CREATE TABLE

Paste JSON rows and pick a database to get a table that fits the data before you import it.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter json input, table name and database.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Rows are merged and every key becomes a column. Whole numbers become INTEGER, or BIGINT above 2147483647; decimals become DOUBLE, REAL or FLOAT; text becomes TEXT or VARCHAR(255); objects and arrays become JSON or JSONB by database. A column present in every row without null gets NOT NULL.

Example

Inputs: Table name = customers, Database = PostgreSQL. Result: SQL statement: CREATE TABLE "customers" ( "id" INTEGER NOT NULL, "name" TEXT NOT NULL, "city" TEXT NOT NULL, "balance" DOUBLE PRECISION NOT NULL, "is_active" BOOLEAN NOT NULL, "joined" TEXT NOT NULL, "notes" TEXT );; Columns: 7; Rows in the sample: 2.

[
  { "id": 1, "name": "Sara Ahmed", "city": "Riyadh", "balance": 1520.75, "is_active": true, "joined": "2025-03-14" },
  { "id": 2, "name": "Omar Khalid", "city": "Dubai", "balance": 980, "is_active": false, "joined": "2025-06-02", "notes": null }
]
CREATE TABLE "customers" (
  "id" INTEGER NOT NULL,
  "name" TEXT NOT NULL,
  "city" TEXT NOT NULL,
  "balance" DOUBLE PRECISION NOT NULL,
  "is_active" BOOLEAN NOT NULL,
  "joined" TEXT NOT NULL,
  "notes" TEXT
);

Limits and caveats

  • It sets no primary key or indexes; add them after reviewing the table.
  • Dates written as text stay text, because JSON has no date type.

Questions about this tool

When does a column get NOT NULL?

When the key appears in every row of the sample and is never null.

What happens to nested objects and arrays?

They become a JSONB column in PostgreSQL, JSON in MySQL, and text in SQLite and SQL Server.

Why are column names quoted?

So names with spaces or reserved words, such as "order" or [my table], still work.