DevTools

JSON to SQL

Infer a SQL CREATE TABLE from a JSON sample or a JSON Schema — column types, nullability, and a primary-key guess — for PostgreSQL, MySQL, or SQLite. Runs in your browser.

Prefer the terminal? See the CLI equivalent →
Loading tool…

About the JSON to SQL

  • Postgres, MySQL & SQLite
  • JSON sample or JSON Schema
  • Related tables & foreign keys
  • Syntax highlighting
  • Instant results
  • 100% private — runs in your browser
  • Free, no sign-up

Turn JSON into a CREATE TABLE statement — from either a JSON sample or a JSON Schema. In sample mode each key becomes a column typed from the values across every row; in schema mode each property becomes a column, with the schema’s "required" list driving NOT NULL and "format"/"maxLength" refining the type. A column named "id" is treated as the primary key.

Pick your database — PostgreSQL, MySQL, or SQLite — and the types and identifier quoting adjust accordingly. Strings that look like a UUID, date, or timestamp (by value or by schema format) map to the dialect’s dedicated type. By default, nested objects and arrays map to the JSON type (JSONB / JSON / TEXT); turn on “Split nested into related tables” to normalize them into separate child tables linked by foreign keys instead.

It’s a fast way to bootstrap a schema from an API response, a data sample, or an existing JSON Schema. Everything runs in your browser — nothing is uploaded — and any JSON-producing tool here can send its output straight in.

How to use it

  1. Choose “JSON sample” and paste an object/array, or “JSON Schema” and paste a schema.
  2. Choose the SQL dialect and set the table name.
  3. Read the generated CREATE TABLE on the right.
  4. Review the inferred types and nullability, then copy or download the .sql file.

How types are inferred

Integer / big integer
Whole numbers → INTEGER, or BIGINT past 32 bits.
Float
Non-integer numbers → DOUBLE PRECISION / DOUBLE / REAL.
Boolean
true/false → BOOLEAN (INTEGER in SQLite).
UUID / date / timestamp
Recognized string formats map to the matching column type.
Object / array
Nested values → JSONB / JSON / TEXT (default), or a child table.
Split nested
Optional: nested objects & arrays become child tables with foreign keys.
NOT NULL
Added when every row has a non-null value for the column.
PRIMARY KEY
Guessed for a column named "id".

Frequently asked questions

What input does it expect?+

Either a JSON sample or a JSON Schema. A sample can be one object or an array of objects (columns are the union of keys, typed from every row). A schema should describe an object — or an array of objects via "items" — whose "properties" become the columns.

How does JSON Schema mode differ from a sample?+

A schema is authoritative rather than inferred: "required" decides NOT NULL, "type" gives the column type (including nullable via a ["string","null"] union), and "format" (uuid, date, date-time) and "maxLength" refine it — e.g. a maxLength becomes VARCHAR(n) and format: "date-time" becomes TIMESTAMP/DATETIME.

How is nullability decided?+

A column is NOT NULL only if it is present and non-null in every row. If any row omits it or sets it to null, it’s left nullable.

How are nested objects and arrays handled?+

By default they map to the dialect’s JSON type — JSONB on PostgreSQL, JSON on MySQL, TEXT on SQLite. Enable “Split nested into related tables” to normalize instead: each nested object and each array of objects becomes its own child table with a foreign key back to the parent, arrays of scalars become a child table with a value column, and any table without its own id gets a synthesized auto-increment primary key. Child tables are named parent_child by default; untick “Prefix child tables with parent name” to use bare key names (with a numeric suffix if two would collide).

Is my JSON uploaded?+

No. Parsing and SQL generation run entirely in your browser; nothing is sent to a server.

Works well with

JSON to SQL chains with these tools — send your result straight on:

Related tools