Convert JSON to SQL INSERT statements

Turn a JSON array of objects into SQL INSERT statements and a CREATE TABLE, with nested objects flattened into columns and types read from the JSON.

Drop your JSON file here or click to choose a file JSON file · processed on this device

How to convert JSON to SQL

  1. 1

    Choose a .json or .jsonl file

  2. 2

    Name the table and pick the SQL dialect

  3. 3

    Download the SQL

From an API response to a table you can load

JSON is how most APIs and exports hand over records, and a database is where many of those records need to go. Between the two there is usually a short script: read the file, loop over the objects, escape the quotes, write INSERT statements, and hope a name with an apostrophe in it does not break the batch. This writes that script’s output for you.

What it writes

An INSERT statement for every hundred records, or for every 250, 500 or 1,000 if you choose, with every column named. Ticked by default, a CREATE TABLE comes first, with a column for every key found in any record, so the table the statements fill exists before they run. Table and column names are quoted, so a column called order or first name works, and a table name can include a schema, as in public.customers.

Types

A CSV cell is always text, so CSV to SQL has to guess at types. JSON does not need guessing: it says which values are numbers, which are true or false, which are null and which are strings. Those types decide the CREATE TABLE, and values are written to match, so a number goes in bare, true becomes TRUE and null becomes NULL. A key a record leaves out is NULL too.

A string stays a string even when it is all digits, because “02134” is a postcode and “007” a code, and writing them as numbers would drop the zero. Some APIs quote every number, though. For those, tick Read numbers written as text, and the columns are typed by the same rule CSV to SQL uses.

Nested data

A record with an object inside it, such as an address with a city and a postcode, is flattened into dotted columns: address.city and address.postcode. That is the shape Flatten JSON and JSON to CSV write. An array stays in one column as JSON text. A file of one record a line, saved as .jsonl or .ndjson, is read a line at a time.

Dialects

Standard SQL quotes names with double quotes, which PostgreSQL and SQLite read. MySQL and MariaDB read a double-quoted name as a string unless ANSI_QUOTES is set, so their dialect uses backticks and doubles every backslash in a value. Check the types before loading anything that matters; the file says so in its first line.

Everything you need

Types from the JSON

Numbers, true and false, null and text keep the types JSON gave them, with a CREATE TABLE to match.

Quoted for your database

Standard double quotes for PostgreSQL and SQLite, or backticks for MySQL and MariaDB.

Private by design

The JSON is converted in your browser and never sent anywhere.

Nothing uploaded: open the Network panel while it runs and check.

No daily limits or watermarks: free batches take up to 20 images.

Works offline: once the page has loaded, on any current browser.

Frequently asked questions

How are the column types chosen?

From the JSON itself. A column of whole numbers is INTEGER, of other numbers NUMERIC, of true and false BOOLEAN, and anything else TEXT. A string of digits such as "02134" stays TEXT, because JSON wrote it in quotes. Tick Read numbers written as text for an API that quotes every number.

What happens to nested objects and arrays?

A nested object becomes dotted columns, so address.city is its own column, the way JSON to CSV and Flatten JSON write it. An array is written as JSON text in one column, or every nested value can be kept as JSON text with the Nested objects option.

What if the records are inside a wrapper such as data or results?

The list of records is found inside it, the same way JSON to CSV finds it, and the result names the key it read. A record that leaves a key out gets NULL in that column.

Is the file uploaded?

No. The SQL is written in this browser tab and the JSON never leaves your device.

Sources

Related guides

Work with files privately and confidentlyPractical, sourced explanations for safer file conversion, sharing, and cleanup.