JSON to SQL Schema (CREATE TABLE)

Infer a table definition with column types and constraints from example JSON records.

100% Client-Side Processing — your data never leaves this browser. Works offline. How it works

0 lines • 0 bytes Ready
Tip: drop a file anywhere on the editor
Input
Paste, type or drop a file
1
Result
Updates as you type
// Output will appear here…
About this tool

How the JSON to SQL Schema works

Generate a CREATE TABLE statement from sample JSON. Column types, NOT NULL and the primary key are detected for MySQL, PostgreSQL, SQLite and SQL Server.

How to use the JSON to SQL Schema

  1. Paste one or more sample JSON records.
  2. Name the table and choose the SQL dialect.
  3. Copy the CREATE TABLE statement and adjust it if needed.

JSON to SQL Schema example

Input
[{"id":1,"name":"Aarav","joined":"2026-01-19","score":9.5},{"id":2,"name":"Sara","joined":"2026-02-07","score":null}]
Result
CREATE TABLE IF NOT EXISTS "members" (
  "id" INTEGER PRIMARY KEY,
  "name" VARCHAR(50) NOT NULL,
  "joined" DATE NOT NULL,
  "score" DOUBLE PRECISION
);

When to use it

  • Designing a table to store data from a third-party API.
  • Writing the first migration for a new feature.
  • Documenting the shape of a JSON dataset as SQL.

Tip: Use JSON to SQL afterwards with the same table name to generate the matching INSERT statements.

Type inference

INTEGER/BIGINT, DOUBLE, BOOLEAN, DATE, TIMESTAMP, VARCHAR(n) or TEXT are chosen from the values in each column.

Constraints

Columns with a value in every record get NOT NULL; an integer id column with unique values becomes the PRIMARY KEY.

JSON columns

Nested objects and arrays map to JSON (MySQL), JSONB (PostgreSQL) or text columns.

Per-dialect types

The same data produces DATETIME2 and NVARCHAR on SQL Server, TIMESTAMP and JSONB on PostgreSQL.

FAQ

Common questions

How many records should I paste?

Several. With more examples the types and NOT NULL constraints are more accurate, because a single record cannot show which fields are optional.

How is VARCHAR length chosen?

From the longest value seen, rounded up to 50, 100 or 255; longer text becomes TEXT (NVARCHAR(MAX) on SQL Server).

Can I turn off the primary key?

Yes, untick "id as PRIMARY KEY".

Should I use the output as-is?

Treat it as a strong first draft. Add indexes, foreign keys and exact lengths based on what you know about the data.