JSON to SQL Converter

Convert JSON to SQL INSERT statements and an optional CREATE TABLE for MySQL, PostgreSQL, SQLite or SQL Server with correct quoting and escaping. Free.

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is JSON to SQL?

Turn a JSON array of objects into SQL: an optional CREATE TABLE with inferred column types followed by INSERT statements. Identifiers and strings are quoted and escaped for the dialect you choose.

How to use JSON to SQL

  1. Paste JSON into the JSON input box, or use Load sample or Open file.
  2. Choose the SQL dialect and enter the Table name.
  3. Toggle Include CREATE TABLE and Multi-row INSERT.
  4. The SQL output updates as you type; use Copy or Download.

Example

Input
[{"id":1,"name":"O'Brien"}]
Output
CREATE TABLE `my_table` (
  `id` INT,
  `name` VARCHAR(255)
);

INSERT INTO `my_table` (`id`, `name`) VALUES
  (1, 'O''Brien');

When to use JSON to SQL

Use it to seed a database from JSON exports, fixtures or API data. Review the generated column types and add primary keys, NOT NULL and indexes yourself – they cannot be inferred from sample data.

How JSON to SQL works

Columns are the union of all object keys. Each column's type is inferred from its non-null values: integers → INT/INTEGER (BIGINT above 32 bits), decimals → DOUBLE / DOUBLE PRECISION / REAL / FLOAT, booleans → BOOLEAN (BIT in SQL Server, INTEGER in SQLite), strings → VARCHAR(255) or TEXT/NVARCHAR(MAX) depending on length, nested objects/arrays → JSON/JSONB or text. Identifiers use backticks (MySQL), double quotes (PostgreSQL, SQLite) or brackets (SQL Server). Strings double their single quotes; MySQL also escapes backslashes, and SQL Server uses N'…' for non-ASCII text. Multi-row inserts are split into chunks of 1000 rows for SQL Server.

Common Use Cases

  • Seed a development database from a JSON fixture
  • Import API data into PostgreSQL
  • Create a quick SQLite table from JSON for analysis
  • Generate INSERT statements for a migration script

FAQs

Is the SQL safe against injection?

All string values are escaped for the selected dialect, but always review generated SQL before running it on production data.

How are nested objects stored?

As JSON text in a JSON (MySQL), JSONB (PostgreSQL) or text column.

Why does SQL Server output several INSERT statements?

SQL Server allows at most 1000 rows in one VALUES list, so larger inputs are split.

Good next steps

Explore more categories