JSON-Utils

JSON to SQL CREATE TABLE

Generate a CREATE TABLE statement from a JSON sample, with column types inferred from the values. Pick the dialect and the types, quoting, and JSON support follow it. Nested objects either flatten into prefixed columns or become a single JSON column, and arrays can become native PostgreSQL arrays, JSON columns, or separate child tables with a foreign key.

JSON
SQL DDL
Result will appear here
Ready. Press Generate or Ctrl+Enter.

How to use the JSON to SQL CREATE TABLE

  1. Paste a JSON sample, ideally one row of the table you want.
  2. Choose the dialect. Type names, quoting, and array support all follow the dialect.
  3. Decide how nested objects and arrays are stored, then press Generate.

Example

The tags array becomes a TEXT[] column and the author object flattens into prefixed columns.

{
  "name": "json-utils",
  "version": "1.0.0",
  "private": false,
  "tags": ["json", "tools"],
  "author": { "name": "Ada", "active": true },
  "score": 9.5,
  "notes": null
}

Frequently asked questions

How are arrays handled outside PostgreSQL?

Only PostgreSQL has native array columns. In MySQL, SQLite, and SQL Server, the native array choice falls back to a JSON column, or you can pick child tables to get a second CREATE TABLE with a foreign key.

Which keys become NOT NULL?

Keys present in every row of the sample with non null values. A key missing from some array elements, or null anywhere, becomes a nullable column.