Skip to main content

JSON to SQL Table (DDL)

Generate a SQL CREATE TABLE from JSON for PostgreSQL, MySQL or SQLite. Guesses column types, nullability and a primary key. Free and private.

JSON

Stays in your browser

SQL

The result appears here after you press Convert.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Next steps

Done here? Use the Send to… menu on the result to carry it on to SQL Formatter.

Free Online JSON to SQL Table (DDL)

Paste a JSON sample and get a table definition. Column types, which columns may be empty and the primary key are guessed from your data. It gives developers a quick browser-based way to solve a focused json to sql table (ddl) task before moving the result into a project.

How to use JSON to SQL Table (DDL)

Paste your data into the box on the left, or open a file, then press Convert. Use a list of objects: every key becomes a column. Nested objects become columns joined with underscores; lists become JSON columns.

Common mistakes

  • Using one sample row: types and nullability are only as good as the data you show, so paste several rows.
  • Treating the guess as a design: review lengths and indexes before running the SQL.

Frequently asked questions

How is the primary key guessed?
A column named id, _id, uuid or <table>_id whose values are all present and different becomes the primary key. If none qualifies, none is added.
Which columns are NOT NULL?
A column is NOT NULL when every item has a value for it. A missing or null value makes it nullable.
What about nested data?
Nested objects are flattened into columns such as address_city. Lists, and objects you want to keep whole, become JSON columns (JSONB in PostgreSQL).
Is my data uploaded anywhere?
No. The conversion runs in your browser and nothing you paste or open is sent to a server.
How do I use this json to sql table (ddl) tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More Formatters & Parsers

View all Formatters & Parsers tools →