JSONGenerator
GeneratorSchemaConvertersExamplesDocs

JSONGenerator

Free online tools for generating random JSON data and JSON Schemas.

Quick Links

  • JSON Generator
  • JSON Schema Converter
  • Examples
  • Docs
  • Blog
  • About
  • Contact
  • Privacy Policy

Converters

  • JSON to YAML
  • YAML to JSON
  • XML to JSON
  • JSON to XML
  • JSON to TOML
  • TOML to JSON
  • JSON to CSV
  • CSV to JSON
  • JSON to Excel
  • Excel to JSON
  • JSON to HTML table
  • JSON to TypeScript
  • JSON to C#
  • JSON to Go
  • JSON to Java
  • JSON to SQL

Support

Having issues? Contact us.

© 2026 JSON Generator. All rights reserved.

JSON to SQL Converter

Paste a JSON array and get a CREATE TABLE statement and INSERT rows for PostgreSQL, MySQL, SQLite or SQL Server.

JSON Input

Paste a JSON array of objects, upload a .json file or drop one here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[
  {
    "id": 1,
    "name": "Ada Lovelace",
    "email": "ada@example.com",
    "age": 36,
    "balance": 1250.75,
    "active": true,
    "signed_up": "2024-03-15",
    "last_login": "2025-01-20T08:30:00Z",
    "tags": ["admin", "math"],
    "address": { "city": "London", "zip": "N1 9GU" },
    "bio": "Wrote the first \"program\"; it's famous."
  },
  {
    "id": 2,
    "name": "Grace O'Hara",
    "email": "grace@example.com",
    "age": null,
    "balance": 0,
    "active": false,
    "signed_up": "2024-06-02",
    "last_login": null,
    "tags": [],
    "address": { "city": "Dublin", "zip": "D02 X285" }
  }
]

SQL Output

Updates as you type. Copy it or download a .sql file.

1

Converting…

Convert JSON to SQL online

This free JSON to SQL converter turns a JSON array into a CREATE TABLE statement and ready-to-run INSERT statements. Paste an API response, a database export or test data, choose PostgreSQL, MySQL, SQLite or SQL Server, and the script appears as you type. Nothing is uploaded: the conversion runs in your browser, so it is safe to use with real records.

It is built for the everyday jobs that come up when data starts life as JSON: loading an API dump into a local database, seeding a development or CI database, or moving a document export into a relational table. If you only need to see the shape of your data, the column types in the generated CREATE TABLE show how the converter read each field.

How to convert JSON to SQL

  1. Paste a JSON array of objects into the JSON Input editor, or click the upload button to open a .json file. You can also drag a file onto the editor.
  2. Type a Table name, such as users or public.users, and choose the Dialect that matches your database.
  3. Leave Include CREATE TABLE ticked to get the table definition as well, or untick it to generate only the INSERT statements for a table that already exists.
  4. Check the SQL Output. If the JSON is invalid, the status bar shows the parser's error so you can fix it.
  5. Click Copy to put the SQL on your clipboard, or Download to save it as data.sql, then run it in psql, the MySQL client, the sqlite3 shell or SQL Server Management Studio.

JSON to SQL example

This JSON to SQL table example uses the PostgreSQL dialect and a table named products. The third object has no active, created or tags keys, so those columns get NULL in that row. The apostrophe in O'Brien is doubled so the string stays valid.

JSON input
[
  { "id": 1, "name": "Ada", "active": true, "price": 19.99, "created": "2025-01-20", "tags": ["a", "b"] },
  { "id": 2, "name": "O'Brien", "active": false, "price": 5, "created": "2025-02-03", "tags": [] },
  { "id": 3, "name": "Grace", "price": null }
]
SQL output (PostgreSQL)
CREATE TABLE "products" (
  "id" INTEGER,
  "name" TEXT,
  "active" BOOLEAN,
  "price" DOUBLE PRECISION,
  "created" DATE,
  "tags" JSONB
);

INSERT INTO "products" ("id", "name", "active", "price", "created", "tags") VALUES
  (1, 'Ada', TRUE, 19.99, '2025-01-20', '["a","b"]'),
  (2, 'O''Brien', FALSE, 5, '2025-02-03', '[]'),
  (3, 'Grace', NULL, NULL, NULL, NULL);

How the JSON to SQL conversion works

The converter collects every key that appears in any object, in the order it first appears, and makes each one a column. It then looks at all the values in that column to decide the type. The table shows what each JSON value becomes in the four dialects.

JSON values and the SQL column types they produce
JSON valuePostgreSQLMySQLSQLiteSQL Server
Whole numberINTEGERINTINTEGERINT
Whole number above 2,147,483,647BIGINTBIGINTINTEGERBIGINT
Decimal numberDOUBLE PRECISIONDOUBLEREALFLOAT
true / falseBOOLEAN, TRUE/FALSEBOOLEAN, TRUE/FALSEINTEGER, 1/0BIT, 1/0
Short string (255 characters or fewer)TEXTVARCHAR(255)TEXTNVARCHAR(255)
Longer stringTEXTTEXT or LONGTEXTTEXTNVARCHAR(4000) or NVARCHAR(MAX)
Date such as 2025-01-20DATEDATETEXTDATE
ISO 8601 timestampTIMESTAMP or TIMESTAMPTZDATETIME (UTC)TEXTDATETIME2 or DATETIMEOFFSET
Object or arrayJSONBJSONTEXTNVARCHAR(MAX)
null or missing keyNULLNULLNULLNULL

Types are inferred from every row

A column is only typed as a number if every non-null value in it is a number. Whole numbers mixed with decimals become a floating-point column, and a date mixed with a timestamp becomes a timestamp. Any other mix, such as 1 in one row and "two" in the next, becomes a text column, and the values are stored as their text. A column that is null in every row has no evidence to go on, so it becomes text.

Every column is nullable, and no primary key or index is added, because a sample of JSON cannot tell which fields are unique. Add a PRIMARY KEY or NOT NULL yourself once you have checked the data. Decimals use floating-point types, so change a price column to NUMERIC or DECIMAL if you need exact arithmetic. Also remember that JavaScript reads numbers as 64-bit floats, so integers larger than 9,007,199,254,740,991 lose precision and are typed as floating point.

Nested objects and arrays

Relational tables are flat, so a nested object or array is written as JSON text into one column. In PostgreSQL and MySQL that is a real JSONB or JSON column you can query with ->> or JSON_EXTRACT. SQLite and SQL Server have no separate JSON type, so the column is text, but json_extract and JSON_VALUE work on it. If you want a child table instead, take the nested array out of the document and convert it as its own input.

Dates and timestamps

JSON has no date type, so the converter recognizes ISO 8601 strings: 2025-01-20 and 2025-01-20T08:30:00Z, with optional fractional seconds and a Z or offset. Impossible dates such as February 30 stay plain strings. PostgreSQL uses TIMESTAMPTZ and SQL Server uses DATETIMEOFFSET when any value in the column has a zone. MySQL's DATETIME has no zone, so values with an offset are converted to UTC. SQLite has no date type, so dates stay as ISO text, which sorts and compares correctly.

Escaping and dialect differences

Single quotes inside values are doubled, and column and table names are always quoted, with the quote character escaped, so odd keys such as first name work. MySQL also treats a backslash as an escape character in strings, so backslashes are doubled for that dialect. SQL Server text gets the N prefix so non-ASCII characters survive. Rows are grouped into INSERT statements of up to 500 rows, which stays under SQL Server's limit of 1,000 rows per statement. A dotted table name such as public.users is split into schema and table.

Which JSON shapes are supported

The best input is an array of objects. A single object becomes one row. If an object contains an array of objects, such as { "users": [ ... ] }, the first such array is used as the rows, which suits most API responses. If you really want the outer object as a row, wrap it in square brackets.

Why convert JSON to SQL?

  • Seeding development and test databases: Generate fixtures as JSON, then turn them into INSERT statements you can commit and run in CI.
  • Loading API responses: Put the output of a REST API into a table so you can query, join and aggregate it with SQL.
  • Migrating from document stores: Move a JSON export from a document database into PostgreSQL, MySQL or SQL Server.
  • Quick analysis in SQLite: Load a JSON file into SQLite to explore it with a few queries, without writing an import script.
  • Learning and prototyping: See what schema a JSON document implies before you design the real tables.

Seeding is the most common reason, and our guide to seeding test databases in CI/CD covers how to do it reliably. You can create realistic rows with the JSON Generator and paste them straight into this converter. For bulk loads and spreadsheets, try the JSON to CSV converter or the JSON to Excel converter. To describe the same data as types in code, use JSON to TypeScript, or build a JSON Schema to validate the data before you load it.

Frequently Asked Questions

How do I convert JSON to SQL?

Paste a JSON array of objects into the JSON Input editor, or upload a .json file. Pick your database, set a table name, and the CREATE TABLE and INSERT statements appear as you type. Copy them, or click Download to save data.sql.

How does the converter choose column types?

It reads every row, not just the first. Whole numbers become INTEGER or BIGINT, other numbers a floating-point type, true/false a boolean type, ISO 8601 strings a DATE or timestamp type, and nested objects and arrays a JSON type. A column that mixes types falls back to text.

Can I convert JSON to MySQL, PostgreSQL, SQLite and SQL Server?

Yes. The Dialect option switches identifier quoting, boolean literals and column types between PostgreSQL, MySQL, SQLite and SQL Server. For example, nested JSON becomes JSONB in PostgreSQL, JSON in MySQL, and text in SQLite and SQL Server.

How are nested objects and arrays stored?

Each nested object or array is written as JSON text into a single column, using JSONB on PostgreSQL and JSON on MySQL. The converter does not split nested data into child tables, so you can query it with your database's JSON functions or convert the nested array on its own.

What JSON shapes does it accept?

An array of objects is the standard input, with one row per object. A single object becomes one row, and if an object holds an array of objects, such as {"users": [...]}, that array is used as the rows. Wrap an object in [ ] to force it to be treated as a single row.

Is it safe to run the generated SQL?

Single quotes in values are doubled and identifiers are quoted, so values and key names cannot break out of their string or name. It is meant for seeding and importing data. In application code, use parameterized queries instead of building SQL strings.

Is my JSON uploaded to a server?

No. The conversion runs entirely in your browser with JavaScript, so your data never leaves your device. That makes it fine to use with exports that contain customer or internal records.

Related converters

  • JSON to TypeScript ConverterGenerate TypeScript interfaces or types from a JSON sample.
  • JSON to C# Class ConverterGenerate C# classes with properties for System.Text.Json or Newtonsoft.Json from JSON.
  • JSON to Go Struct ConverterGenerate Go structs with json tags from a JSON sample.
  • JSON to Java Class ConverterGenerate Java POJO classes with getters and setters from JSON.
  • JSON to YAML ConverterConvert JSON to clean, readable YAML for config files, Kubernetes and CI pipelines.
  • YAML to JSON ConverterConvert YAML, including anchors and multi-document files, to formatted JSON.

See all JSON converters