Productivity and Utilities

JSON to SQL Table Generator

Write CREATE TABLE and INSERT statements from an array of JSON records.

An array of objects, or one object. Up to 2,000,000 characters and 100,000 records. Nothing is uploaded.

Use table or schema.table. The name is quoted for you.

Lists stay as JSON text either way.

From 1 to 5,000. SQL Server allows 1,000 at most.

Optional. It must be in every record with no repeats.

Review this SQL before you run it on a real database. Types are chosen from the values by simple rules (whole numbers, decimals as double precision floats, booleans, real dates, then text), so they may need changes for your design. Money should usually be NUMERIC, not a float. Run it on a test copy first.

Next step

How to use the json to sql table generator

  1. Paste JSON records: an array of objects, or one object. A sample with several value types is loaded.
  2. Enter a table name and choose the database. Names are quoted for you in the style that database expects.
  3. Decide how nested objects are handled (stored as JSON text or flattened to columns), pick the INSERT style and the rows per statement, and optionally name a primary key column.
  4. Copy the SQL or download it as a .sql file, then review it before running it on a real database.

One record, one table

The JSON [{"id": 1, "name": "Ann"}] produces CREATE TABLE "people" with an id column of type INTEGER and a name column of type TEXT, followed by one INSERT with the values (1, 'Ann').

If a second record adds "active": true, the table gets an active BOOLEAN column and the first record gets NULL there, because the column list is the union of every key in first-seen order.

How column types are chosen

Each column is checked against every record. All whole numbers give INTEGER, or BIGINT when a value is larger than 2,147,483,647. Any decimal gives a double precision float. All booleans give BOOLEAN (BIT in SQL Server). Strings that are all real calendar dates such as 2024-02-29 give DATE, and strings that are all date and time stamps give TIMESTAMP. A column that mixes kinds, such as numbers and text, falls back to text, and numbers in it are written as quoted text.

A missing key or a null becomes NULL. Lists and objects that remain after your nesting choice are written as JSON text, in a JSON or JSONB column where the database has one.

Quoting and safety

Text is wrapped in single quotes with any single quote doubled, so O'Brien is written 'O''Brien'. For MySQL a backslash is doubled too, and SQL Server text gets the N prefix so Unicode letters survive. Table and column names are quoted with double quotes, backticks or square brackets, with any quote character inside the name doubled.

The output is a script for you to read. Types are guesses, money is better stored as NUMERIC than as a float, and a text primary key may need a length in your database. Run the script on a test copy first. Related tools are the CSV to SQL converter, the JSON schema generator and the test data generator.

Limits

The tool accepts up to the same text size as the JSON formatter, 100,000 records and 500 different keys. Numbers are read as ordinary JavaScript numbers, so integers beyond 15 digits can lose precision before the SQL is written. Nothing is uploaded and no database is contacted.

Assumptions and limits

  • Column types are guesses from the values and should be reviewed.
  • Decimal numbers become double precision floats, not exact NUMERIC types.
  • Text is escaped by the rules of the database you pick, and other settings in your system may differ.
  • SQL Server statements hold at most 1,000 rows each.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

How do I turn JSON into a SQL table?

Paste an array of objects, enter a table name and pick your database. The tool lists every key as a column, chooses a type for each and writes INSERT rows.

What happens to nested objects?

You choose. Store as JSON text keeps each object in one column. Flatten to columns turns {"addr": {"city": "X"}} into a column called addr_city.

Why is my ID column text?

If a column holds numbers in some records and text in others, it cannot be one number type, so it is written as text. Make the values the same kind to get a number column.

Can I choose a primary key?

Yes. Type the column name. It must exist in every record with no repeated values, or the tool explains the problem instead of writing a key that would fail.