JSON ↔ SQL Converter

Convert instantly in your browser. Max file size: 100 MB. Nothing is stored on the server.

Free: 6 / 6 left today • 100 MB
Input
Drop file to upload
Output

Turn a JSON array into ready-to-run CREATE TABLE and INSERT statements, or turn a SQL query into clean JSON. One free tool, four database dialects, no signup.

JSON converts to a SQL table and backA JSON document on the left connects with two-way arrows to a SQL table on the right.JSON[{ “id”: 1,“name”: “Alice”,“active”: true },{ “id”: 2,“name”: “Bob”,“active”: false }]JSON → SQLSQL → JSONSQL TABLE: usersidnameactive1AliceTRUE2BobFALSEMySQL · PostgreSQL · SQLite · SQL Server
JSON to SQL and SQL to JSON, in both directions.

What is JSON to SQL?

JSON to SQL means turning JSON data into statements a relational database understands. Typically that is a CREATE TABLE statement that defines the columns and INSERT statements that load the rows. JSON is the default format of web APIs, exports and config files, while SQL databases expect rows and columns, so a conversion step sits between the two.

This JSON to SQL converter reads an array of objects, maps each key to a column, infers a sensible data type for it and writes SQL for the database you choose. The reverse direction, SQL to JSON, takes a query and produces the JSON expression that returns your result set as a JSON document.

How to convert JSON to SQL

Four steps: paste JSON, choose dialect, convert, run SQL1Paste JSONarray of objects2Pick database+ table name3ConvertCREATE + INSERT4Copy & runin your SQL client
Convert JSON to SQL in four steps.
  1. Paste your JSON or upload a .json file. Validate it first with the JSON formatter and validator if you are unsure it is well formed.
  2. Choose your database (MySQL, PostgreSQL, SQLite or SQL Server) and name the table.
  3. Click convert. The tool generates the table definition and the insert statements.
  4. Copy or download the SQL and run it in your database client.

Example input:

[
  {"id": 1, "name": "Alice", "email": "alice@example.com", "active": true, "tags": ["admin", "editor"]},
  {"id": 2, "name": "Bob",   "email": "bob@example.com",   "active": false, "tags": []}
]

PostgreSQL output:

CREATE TABLE users (
  id     INT PRIMARY KEY,
  name   VARCHAR(255) NOT NULL,
  email  VARCHAR(255),
  active BOOLEAN,
  tags   JSONB
);

INSERT INTO users (id, name, email, active, tags) VALUES
  (1, 'Alice', 'alice@example.com', TRUE,  '["admin","editor"]'),
  (2, 'Bob',   'bob@example.com',   FALSE, '[]');

Want the result tidy before you share it? Run it through the SQL formatter.

How to convert SQL data into JSON format

To convert a SQL query to JSON, you wrap a normal SELECT in your database’s JSON functions. The syntax differs for every engine, which is why a generator saves time. Enter your query and pick a dialect, and the tool produces the right expression:

SQL query result rows become a JSON arraySELECT id, nameFROM users;1 │ Alice2 │ BobJSON functions[{“id”:1,”name”:”Alice”},{“id”:2,”name”:”Bob”}]
A query result becomes a JSON array.
Database SQL to JSON expression
PostgreSQL SELECT json_agg(t) FROM (SELECT id, name FROM users) t;
MySQL SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'name', name)) FROM users;
SQL Server SELECT id, name FROM users FOR JSON PATH;
SQLite SELECT json_group_array(json_object('id', id, 'name', name)) FROM users;

All four return the same JSON: [{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}].

Converting JSON to a SQL table

When you convert JSON to a SQL table, the hardest part is choosing column types. The converter reads your values and maps them like this:

JSON value types and the SQL column types they map to“text”VARCHAR / TEXT42INT / BIGINT3.14DOUBLEtrueBOOLEAN“2026-10-27”DATE / TIMESTAMP{ } [ ]JSON / TEXT
JSON value types (top) and typical SQL column types (bottom).
JSON value PostgreSQL MySQL SQLite SQL Server
String VARCHAR / TEXT VARCHAR / TEXT TEXT NVARCHAR
Integer INT / BIGINT INT / BIGINT INTEGER INT / BIGINT
Decimal DOUBLE PRECISION DOUBLE REAL FLOAT
Boolean BOOLEAN TINYINT(1) INTEGER BIT
Date string DATE / TIMESTAMP DATE / DATETIME TEXT DATE / DATETIME2
Object / array JSONB JSON TEXT NVARCHAR(MAX)

Check the generated types before you load production data. Inference works from the values it sees, so a column that is whole numbers in your sample but decimals later may need a manual change.

How nested JSON is handled

Three ways to store nested JSON in SQLNested JSON{ “a”: { “b”: [] } }JSON / JSONB column– keep structure, query with native JSON functionsFlattened columns– address.city becomes address_cityRelated tables– arrays become child rows with a foreign key
Pick the storage style that matches how you will query the data.

Real-world JSON is rarely flat. Objects inside objects and arrays of values do not map to one plain column, so you have three common options: store the fragment in a JSON column (JSONB in PostgreSQL, JSON in MySQL, text in SQLite), flatten it into extra columns, or split arrays into a separate table linked by a key. JSON columns are quickest; related tables are best when you need to filter, join or index on the inner values.

Benefits of using JSON to SQL

Saves time

No hand-writing hundreds of INSERT lines or guessing column types.

Fewer errors

Quotes, apostrophes and special characters are escaped consistently.

Queryable data

Once in tables, you can filter, join, index and aggregate with plain SQL.

Works both ways

Go from API response to database and from database back to JSON.

In short, the main benefit of converting JSON to SQL is that you keep the flexibility of JSON for exchange while gaining the structure, constraints and speed of a relational database for storage and reporting.

Parse JSON in SQL: built-in functions

Every major database can also parse JSON stored in a column, which is useful when you decide to keep a nested fragment as JSON. A few functions to know:

If you need the exact rules for what counts as valid JSON, the format is defined in .

Common use cases

  • Importing API data: save a REST API response into a table for reporting.
  • NoSQL to SQL migration: move MongoDB or Firebase exports into MySQL or PostgreSQL.
  • Seeding test databases: turn sample JSON fixtures into repeatable seed scripts.
  • WordPress and WooCommerce work: load exported product or order data into a custom table.
  • Feeding front ends: convert a SQL query to JSON for charts, dashboards and apps.
  • Other formats: need a spreadsheet instead? Use the JSON to CSV converter.

Best practices

  • Validate first. A stray comma or a single-quoted key will stop any parser.
  • Test on a copy. Run generated SQL on a development database before production.
  • Add keys and indexes. Set primary keys, unique constraints and indexes that match how you query.
  • Use parameterized queries in code. Generated scripts suit one-off imports; applications should bind values rather than build SQL strings. The explains why.
  • Batch large imports. Split very large inserts into several statements to stay under size limits.
Heads up: never paste confidential production data into any online tool unless you trust how it handles your input.

Frequently asked questions

What is JSON to SQL?

It is the conversion of JSON objects into relational database statements, usually a CREATE TABLE definition plus INSERT statements for each record.

How do I convert JSON to SQL?

Paste a JSON array of objects, choose your database and table name, then click convert. Copy the generated SQL into your database client and run it.

How do I convert SQL data into JSON format?

Wrap your SELECT in your database’s JSON functions: json_agg in PostgreSQL, JSON_ARRAYAGG in MySQL, FOR JSON PATH in SQL Server or json_group_array in SQLite.

Can I convert a single JSON object?

Yes. A single object is treated as one row.

Can it handle nested JSON?

Yes. Nested objects and arrays can be kept in a JSON column where the database supports it, or stored as text or flattened.

Which databases are supported?

MySQL, PostgreSQL, SQLite and SQL Server. For MariaDB, start from the MySQL output.

Is the converter free?

Yes, it is free with no signup.

How do I convert other formats to JSON?

Try the XML to JSON converter for XML files.