Skip to content

JSON to SQL converter

JSON to SQL writes a relational staging table from JSON records, so nested data becomes columns before CREATE TABLE and INSERT statements are produced.

  • Converted with Table engine · nothing stored
  • Free: 5 conversions a day · 5 MB each
  • Higher limits →

From real runs

What you get — and what changes

  • CREATE TABLE Changed

    The default PostgreSQL-style output named the table json and inferred column types from the flattened records.

  • Nested objects Changed

    customer.name, customer.city, and extra.gift became quoted SQL column names containing dots.

  • Arrays Changed

    The tags array was written as a JSONB-typed column definition with string literals for each row.

  • String identifiers Kept

    JSON string values 001 and 02134 were inserted as quoted strings, preserving their leading zeroes.

  • Booleans and numbers Kept

    active became TRUE or FALSE and total became unquoted numeric literals in the INSERT statements.

  • Missing nested keys Changed

    extra.gift was NULL for the first record and TRUE for the second because the header is built from all records.

Sample conversions

Flattened table DDL

Input
JSON fields included id, customer.name, customer.city, tags, zip, active, total, due, empty, and extra.gift.
Output
SQL began CREATE TABLE "json" ("id" TEXT, "customer.name" TEXT, "customer.city" TEXT, "tags" JSONB, "zip" TEXT, "active" BOOLEAN, "total" DOUBLE PRECISION, "due" TEXT, "empty" TEXT, "extra.gift" BOOLEAN);

String and boolean literals

Input
Second JSON record had id "002", city 東京, active false, total 19.99, and gift true.
Output
INSERT output included ('002', 'Zoë', '東京', '[]', '94105', FALSE, 19.99, '2026-09-11', NULL, TRUE).

A real JSON → SQL run

We converted our JSON sample (557 B) with Table engine on 2026-09-11. It took 1 ms and produced a 668 B SQL file, 1.2× larger than the input. The engine raised no warnings.

Input · sample.json · 557 B

Array of 4 objects; keys: company, stage, arr, owner, close_date

Records
4
Keys
company, stage, arr, owner, close_date

Output · sample.sql · 668 B

1 CREATE TABLE, 4 INSERT statements

CREATE TABLE
1
INSERT statements
4
Lines
5

First lines of the output

sql
CREATE TABLE "json" ("company" TEXT, "stage" TEXT, "arr" DOUBLE PRECISION, "owner" TEXT, "close_date" TEXT);
INSERT INTO "json" ("company", "stage", "arr", "owner", "close_date") VALUES ('Northwind Traders', 'Proposal', 48000, 'R. Ayers', '2026-10-14');
INSERT INTO "json" ("company", "stage", "arr", "owner", "close_date") VALUES ('Contoso Ltd', 'Negotiation', 120000, 'P. Ng', '2026-09-30');
INSERT INTO "json" ("company", "stage", "arr", "owner", "close_date") VALUES ('Fabrikam', 'Qualified', 22500, 'R. Ayers', '2026-11-02');
INSERT INTO "json" ("company", "stage", "arr", "owner", "close_date") VALUES ('Tailspin Toys', 'Won', 64000, 'M. Okafor', '2026-09-03');

Options and when to change them

flattenSeparator
Change it before SQL generation if dotted identifiers conflict with database naming standards.
arrayMode
Use explode for fixed arrays that should become separate indexed SQL columns.
encoding
Use latin1 only for unusual JSON sources that are not UTF-8.
dialect
Switch to mysql for backtick identifiers or sqlite for SQLite-flavoured generic types.
tableName
Set a staging table name that matches your import script before sharing the SQL.
createTable
Turn this off when a DBA has already created the table and only row inserts are needed.

Do it yourself

pandas json_normalize

bash
python - <<'PY'
import pandas as pd
from sqlalchemy import create_engine
df = pd.json_normalize(pd.read_json("input.json").to_dict(orient="records"))
df.to_sql("json_stage", create_engine("sqlite:///out.db"), if_exists="replace", index=False)
PY

Arrays often need custom normalization before a relational import is trustworthy.

JSON to SQL by API or MCP

The HTTP API and the MCP server run the exact engine this page uses (Table engine); the response carries the same warnings the web converter shows. Check support first with GET /api/v1/pairs?from=json&to=sql.

curl
curl -X POST https://filetypeconverters.com/api/v1/convert \
  -H "Authorization: Bearer $FTC_API_KEY" \
  -F "file=@input.json" -F "from=json" -F "to=sql" \
  -F 'options={"encoding":"utf-8"}' \
  --output output.sql

Options this engine accepts for JSON → SQL

KeyApplies toTypeDefault
encodingReading JSONutf-8 · latin1utf-8
flattenSeparatorReading JSONstring.
arrayModeReading JSONjson · explodejson
dialectWriting SQLpostgres · mysql · sqlitepostgres
tableNameWriting SQLstringdata
createTableWriting SQLbooleantrue
API reference

When this is the wrong conversion

  • Do not use generated SQL as a schema design tool for production tables; it is a staging export.
  • If nested arrays need separate child tables, model them deliberately instead of accepting JSON strings in one column.

JSON to SQL questions

How does JSON to SQL handle nested objects?

Nested properties flatten into quoted column names. The sample produced columns such as customer.name and extra.gift.

Are JSON arrays stored as SQL arrays?

No. In the default PostgreSQL-style output, our table engine typed the column as JSONB and inserted JSON text. It did not create native array columns or child tables.

Why is the default SQL table called json?

The JSON parser names the IR table json, and the SQL writer uses that table name unless overridden. Rename it to a staging table name before loading real data.