Limited Time Offer: 40% off

Free tool

JSON to SQL Converter

Paste a JSON array of objects and get ready-to-run CREATE TABLE and INSERT statements, with a type picked for each column. Nested values become JSON columns. Everything runs in your browser.

Dialect
JSON
SQL · 3 rows
CREATE TABLE "users" (
  "id" INTEGER,
  "name" TEXT,
  "email" TEXT,
  "age" INTEGER,
  "active" BOOLEAN,
  "roles" JSONB
);

INSERT INTO "users" ("id", "name", "email", "age", "active", "roles") VALUES
  (1, 'Alice Ng', 'alice@example.com', 30, TRUE, '["admin","editor"]'),
  (2, 'Bob Ray', 'bob@example.com', 25, FALSE, '["viewer"]'),
  (3, 'Carol Woods', 'carol@example.com', 42, TRUE, '[]');
Everything runs in your browser. Your data is never uploaded or stored.

From an API response to a real table

JSON is the format data arrives in, from an API, a log line, or an export. SQL is the format a relational database wants. Bridging the two by hand means writing a table definition, matching a type to every field, and then turning each object into an INSERT, which is tedious the moment the objects have more than a handful of keys.

This converter reads a JSON array of objects, uses the keys as column names, and looks at the values in each column to choose a type. It writes the CREATE TABLE and the INSERT statements together, so you can paste both into a client and run them.

Types come straight from the JSON

JSON already knows whether a value is a number, a boolean, or a string, so the tool does not have to guess the way a CSV converter does. Whole numbers become an integer type, decimals become a floating point type, and true and false become a boolean. Strings shaped like YYYY-MM-DD become a date, or a timestamp when a time is attached.

Nested objects and arrays are kept rather than flattened. A column that holds them is given a JSON type, which is JSONB on PostgreSQL and JSON on MySQL, and the value is written as a JSON string. When objects in the array have different keys, the tool collects every key it sees and writes NULL for the rows that lack one.

Built for the database you use

The dialect setting changes the column type names and the way identifiers are quoted. PostgreSQL and SQLite quote names with double quotes, MySQL uses backticks, and SQL Server uses square brackets. Booleans are written as TRUE and FALSE for PostgreSQL and as 1 and 0 where that is the convention.

The whole conversion happens in your browser, so an API response or any other sensitive payload stays on your machine. Nothing is uploaded and nothing is saved.

Frequently asked questions

How do I convert JSON to SQL?
Paste a JSON array of objects into the left pane. Each key becomes a column and each object becomes a row. The tool infers a type for every column and writes a CREATE TABLE statement plus INSERT statements you can copy and run. Choose your database dialect first so the types and quoting match.
What shape does the JSON need to be?
An array of objects works best, for example [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]. A single object is accepted too and becomes one row. If different objects have different keys, the tool takes the union of all keys and writes NULL where a value is missing.
What happens to nested objects and arrays?
A column that holds nested objects or arrays is given a JSON type: JSONB on PostgreSQL, JSON on MySQL, and a text type on SQLite and SQL Server. The nested value is stored as a JSON string, so nothing is lost and the structure stays intact.
Does it detect numbers, booleans, and dates?
Yes. Because JSON already carries types, whole numbers become an integer type, decimals become a floating point type, and true and false become a boolean. Strings that look like a date in YYYY-MM-DD form become a date or timestamp, and everything else becomes text.
Which databases are supported?
The output can target PostgreSQL, MySQL, SQLite, SQL Server, or standard SQL. The dialect controls the column type names and how identifiers are quoted, for example double quotes for PostgreSQL, backticks for MySQL, and square brackets for SQL Server.
Is my JSON uploaded anywhere?
No. The conversion runs as JavaScript in your browser, so your data stays on your machine. You can paste a real API response without it being sent to a server.

More free tools

Work with JSON columns in DB Pro

Once your JSON is loaded, DB Pro helps you work with it. It formats and expands JSON and JSONB columns in the data browser, so you can read nested values without squinting at a single line. It is a desktop database client for macOS, Windows, and Linux that works with PostgreSQL, MySQL, SQLite, and more.

Need CSV instead? Try the CSV to SQL converter, browse the other free tools, or read the database tutorials.