Boneyard Tools

JSON to SQL Schema Generator

Paste JSON to generate a CREATE TABLE statement. The tool reads an object or an array of objects, infers a column type for each key from the values across every row, and writes DDL for Postgres, MySQL or SQLite. An id column is marked as the primary key.

How to generate a SQL schema from JSON

  1. Paste your JSON. An array of objects gives the most accurate column types.
  2. Set the table name and choose Postgres, MySQL or SQLite.
  3. Copy the CREATE TABLE statement or download it as a .sql file.

Examples

Array of objects to Postgres DDL

[{"id":1,"name":"Ada","active":true,"score":9.5}]
CREATE TABLE my_table (
  id INTEGER PRIMARY KEY,
  name VARCHAR(255),
  active BOOLEAN,
  score DOUBLE PRECISION
);

Frequently asked questions

Is my data uploaded anywhere?

No. The schema is generated entirely in your browser, so your JSON and the CREATE TABLE output never leave your device. Nothing is uploaded, logged or stored on a server.

How are column types inferred?

Each key is checked across every row. Whole numbers become an integer type, numbers with decimals become a float type, true or false becomes a boolean, and text becomes VARCHAR(255) or TEXT depending on the dialect. A column that mixes types, or holds only null, falls back to TEXT so nothing is lost.

Which dialects are supported?

Postgres, MySQL and SQLite. The structure stays the same and only the type names change: for example an integer is INTEGER in Postgres and SQLite but INT in MySQL, and a float is DOUBLE PRECISION, DOUBLE or REAL respectively. SQLite has no boolean or varchar types, so those map to INTEGER and TEXT.

How is the primary key chosen?

If a column named id exists (case-insensitive), it is marked PRIMARY KEY. Only one primary key is added. If there is no id column, no primary key is emitted and you can add one yourself.

What if my objects have different keys?

The schema uses the union of all keys as the column list, in the order each key first appears. A type is still inferred for every column from whichever rows contain it, so partial or heterogeneous records are handled.

Are table and column names made safe?

Yes. Identifiers are reduced to letters, digits and underscores, and a leading digit is prefixed with an underscore so the name stays valid. This is a generator for trusted data, so review the DDL and adjust types, lengths or constraints before running it.

Related tools