💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Free Online Tool

JSON to PostgreSQL CREATE TABLE

Paste a JSON array of objects, get a PostgreSQL DDL with auto-detected types.

Open the Schema Inferrer →

Overview

When your data lives in JSON — API responses, log lines, NoSQL exports — the schema inferrer flattens the top-level keys into columns and infers PostgreSQL types from the values. Numbers become INT/BIGINT/NUMERIC, true/false becomes BOOLEAN, ISO 8601 strings become DATE or TIMESTAMP, UUID-shaped strings become UUID.

What you get

✓ INCLUDED
Reads JSON arrays of flat objects in one paste
✓ INCLUDED
PostgreSQL types: INT, BIGINT, NUMERIC, BOOLEAN, DATE, TIMESTAMP, UUID, VARCHAR(N), TEXT
✓ INCLUDED
Detects nullable columns from missing or null values
✓ INCLUDED
Numbers with no fractional part stay as INT/BIGINT — no false NUMERIC
✓ INCLUDED
Use the output as a staging table for jsonb_populate_recordset()

Type detection reference

Sample values and the dialect-native type they map to.

Sample valueInferred type
"value": 42INT
"value": 9999999999BIGINT
"value": 12.45NUMERIC(10,2)
"value": trueBOOLEAN
"value": "2024-03-15"DATE
"value": "2024-03-15T09:30:00Z"TIMESTAMP
"value": "a3bb189e-…"UUID
"value": null(nullable)

Example

Input
[
  {"id": 1, "name": "Alice", "score": 9.4, "active": true},
  {"id": 2, "name": "Bob",   "score": 7.2, "active": false}
]
Output
CREATE TABLE users (
    id     INT          NOT NULL,
    name   VARCHAR(16)  NOT NULL,
    score  NUMERIC(2,1) NOT NULL,
    active BOOLEAN      NOT NULL
);

Frequently asked questions

What about nested JSON objects?
We currently flatten only the top level. For nested objects, store the whole record in a JSONB column and use Postgres' JSON operators to query, or pre-flatten with jq before pasting.
Does it handle JSONL (newline-delimited)?
Wrap the lines in [...] with commas between to make a valid JSON array, then paste.
How does it pick VARCHAR length?
We bucket to 16/32/64/128/255/512/1024 based on the longest value seen. Beyond 1024, we use TEXT.

Try it now

No signup, no install — runs entirely in your browser.

Open the Schema Inferrer →

⚠ Confirm Delete