Data & CSV

JSON to SQL

JSON to SQL Converter

Convert a JSON array of objects into CREATE TABLE and INSERT statements.

About this tool

About JSON to SQL

Got an API response or a JSON export that needs to go into a database table? Paste it here and get a CREATE TABLE statement plus batched INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. The converter takes an array of objects (or an object that wraps one, such as {"data": [...]}) and builds one column for every key it finds across all records, so a field that appears only in some objects still gets a column and NULL elsewhere. Numbers, booleans, ISO dates and timestamps get matching SQL types. Nested objects and arrays can either be stored whole in a JSON column (JSONB in PostgreSQL, JSON in MySQL) or flattened into dot-named columns such as shipping.city. Strings are escaped correctly for the chosen database, including apostrophes and backslashes. You can set the table name, primary key, batch size, DROP TABLE IF EXISTS and a transaction wrapper. Nothing is uploaded: the conversion happens in your browser, which matters when the JSON holds customer or production data.

Built and maintained by Abhi JainUpdated

How to Convert JSON to SQL

  1. 1

    Paste JSON

    Paste a JSON array of objects into the left pane, open a .json file, or click Sample.

  2. 2

    Pick database and table

    Choose MySQL, PostgreSQL, SQLite or SQL Server and enter the table name.

  3. 3

    Choose how to store nested data

    Select JSON column to keep nested objects whole, or Flatten a.b to spread them into separate columns.

  4. 4

    Copy the SQL

    Copy the output or download it as a .sql file.

JSON to SQL: questions and answers

What JSON shape does it expect?

An array of objects, like [{"id": 1, "name": "Asha"}, {"id": 2, "name": "Ravi"}]. A single object becomes one row, and an object holding one array (for example {"data": [...]}) is unwrapped automatically.

What happens to nested objects?

With JSON column, each nested object or array is stored as JSON text in a column typed JSONB (PostgreSQL), JSON (MySQL) or text (SQLite, SQL Server). With Flatten, nested keys become columns such as address.city; arrays are still stored as JSON.

What if objects have different keys?

Every key seen in any object becomes a column, in the order first seen. Records without that key get NULL.

Are JSON null values kept?

Yes. null becomes SQL NULL, and the column is left nullable.

Is my JSON sent anywhere?

No. Parsing and SQL generation run entirely in your browser.