1. Home
  2. Developer tools
  3. JSON to SQL

JSON to SQL

Load exported JSON into a database without writing a script: get a table definition and INSERT statements for the database you use.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use JSON to SQL

  1. Paste a JSON array of objects.
  2. Choose the database, table name and options.
  3. Copy or download the .sql file.

Features

  • PostgreSQL, MySQL, SQLite and SQL Server types and quoting
  • Types inferred from every row: INTEGER, BIGINT, DOUBLE, BOOLEAN, DATE, TIMESTAMP, UUID, JSON
  • NOT NULL for columns with no nulls; optional primary key
  • Batched multi-row INSERTs with quotes escaped
  • snake_case column names on request

Supported formats

You can open

  • JSON

You get

  • SQL

Private by design

Your files are opened and processed by your browser on this device. They are never uploaded to openWorkstand or anyone else, so the JSON to SQL is safe for contracts, IDs, photos and work documents. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Nested objects are stored as JSON columns rather than separate tables.
  • Very large files are limited by your device’s memory; use the database’s bulk loader for millions of rows.

Guide

Loading JSON into a SQL database

JSON is how most APIs and exports deliver data, but analysis, joins and reports are easier in a SQL database. Getting a JSON array into a table usually means writing a script: deciding column types, quoting identifiers, escaping strings and splitting the inserts into batches. This converter writes that script for PostgreSQL, MySQL, SQLite or SQL Server.

What it reads

Paste an array of objects, the usual shape of an export or a list endpoint. If the array is wrapped, as in {"data": [...]}, the first array inside the object is used; a single object becomes one row. Every key found in any row becomes a column, so rows with extra keys are not lost.

How column types are chosen

Each column’s type is decided from all of its values, then mapped to the dialect you pick. Whole numbers become INTEGER, or BIGINT when any value exceeds the 32-bit range. Decimals become DOUBLE PRECISION in PostgreSQL, DOUBLE in MySQL, REAL in SQLite and FLOAT in SQL Server. Booleans become BOOLEAN, except in SQLite (INTEGER 0/1) and SQL Server (BIT). Strings in ISO 8601 date form become DATE, date-times become TIMESTAMPTZ, DATETIME or DATETIMEOFFSET, and UUIDs become UUID or the nearest equivalent. Everything else is text; in MySQL, short strings get a VARCHAR sized to the longest value, from 16 up to 255.

Nested data

Objects and arrays inside a row are stored as JSON: JSONB in PostgreSQL, JSON in MySQL, text in SQLite and NVARCHAR(MAX) in SQL Server. You can query them with each database’s JSON functions, or normalise them later into separate tables with their own keys.

Keys, nulls and names

A column gets NOT NULL when every row has a value for it. Name a primary key column, usually id, and it is declared PRIMARY KEY. Turn on snake_case to convert keys such as firstName into the conventional first_name. Identifiers are quoted the way each database expects — double quotes, backticks or square brackets — so keys with spaces or reserved words still work.

Escaping and batching

String values are written as SQL literals with every single quote doubled, so O’Neil becomes 'O''Neil'; MySQL also doubles backslashes, and SQL Server literals get the N prefix for Unicode. Rows are grouped into multi-row INSERT statements, 500 per statement by default, which is much faster than one statement per row and stays within statement-size limits.

A worked example

The sample has three users. In PostgreSQL the table comes out as "id" INTEGER PRIMARY KEY, "first_name" TEXT NOT NULL, "email" TEXT, "active" BOOLEAN NOT NULL, "balance" DOUBLE PRECISION NOT NULL, "joined_at" TIMESTAMPTZ NOT NULL and "prefs" JSONB. The email is nullable because one user has none, and the third user’s name is written 'O''Neil'.

When to use a bulk loader

Generated scripts suit thousands or tens of thousands of rows. For millions, export CSV and use the database’s loader — COPY in PostgreSQL, LOAD DATA INFILE in MySQL, .import in SQLite or BULK INSERT in SQL Server — which is far faster and lighter on memory.

Before running it

Read the column table under the output and adjust anything the sample could not reveal: a code that looks numeric but needs leading zeros should be text, and money is safer as NUMERIC(12,2) than as a floating-point type.

Format the result with the SQL Formatter, convert spreadsheets with CSV to SQL, inspect the JSON first in the JSON Formatter, or turn CSV into JSON with CSV to JSON.

Checked against the current version of the JSON to SQL on .

Troubleshooting

The file does not open

Check that it is one of the supported formats above and opens in another app. Damaged files and password-protected PDFs cannot be read until they are repaired or unlocked.

It is slow or stops on a very large file

Everything runs on your device, so speed depends on its memory. Close other tabs, use a computer rather than a phone, or split the file into smaller parts first.

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why does SQL Server get at most 1,000 rows per INSERT?

SQL Server rejects a VALUES list with more than 1,000 row constructors in one INSERT statement. Smaller batches are split automatically, so the script runs without editing.

How do I run the script?

Save it as a .sql file and run it with your database’s client: psql -f file.sql for PostgreSQL, mysql db < file.sql for MySQL, sqlite3 db.sqlite < file.sql for SQLite, or open it in a GUI such as DBeaver, pgAdmin or SQL Server Management Studio.

Are the values safe from SQL injection?

Every string is written as a quoted literal with its quotes doubled, so text cannot break out of the value. For data from untrusted users in an application, use parameterised queries in code rather than generated scripts.

What happens to nested objects?

They are stored as JSON in a JSONB (PostgreSQL), JSON (MySQL) or text column. To normalise them into their own tables, convert the nested arrays separately and add the foreign keys yourself.

How big a file can I convert?

Tens of thousands of rows work in the browser. For millions of rows, use the database’s own bulk loader (COPY in PostgreSQL, LOAD DATA in MySQL) with a CSV export instead.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.