JSON to SQL Converter

Turn a JSON array of records into a CREATE TABLE statement and INSERT queries for MySQL, PostgreSQL or SQLite.

SQL
Ctrl + Enter to run

Runs 100% in your browser — your data is never uploaded to our server.

Load JSON data into a SQL database

When you need test data in a relational database, or you are migrating records exported from an API, writing INSERT statements by hand is tedious. This converter scans every record to work out each column: its type, and whether it can be NULL (a column becomes nullable if any record has null or is missing the key). It then writes a CREATE TABLE statement and one INSERT per record — or a single multi-row insert if you prefer.

Strings are quoted safely (single quotes are doubled, so O'Reilly becomes 'O''Reilly'), identifiers are quoted with backticks for MySQL and double quotes for PostgreSQL/SQLite, and nested objects or arrays are stored as JSON text (JSON in MySQL, JSONB in PostgreSQL).

Type inference

JSON values in a columnMySQLPostgreSQLSQLite
whole numbersINT / BIGINTINT / BIGINTINTEGER
decimalsDOUBLEDOUBLE PRECISIONREAL
true / falseBOOLEANBOOLEANINTEGER (0/1)
text up to 255 charsVARCHAR(255)VARCHAR(255)TEXT
longer textTEXTTEXTTEXT
objects / arraysJSONJSONBTEXT

How to use it

  1. Paste a JSON array of objects (a single object also works).
  2. Set the table name and SQL dialect.
  3. Review the generated column types — add primary keys, indexes or tighter VARCHAR lengths as needed — then copy or download the .sql file.

Example

JSON

[{"id": 1, "name": "O'Neil", "active": true}]

SQL (PostgreSQL)

CREATE TABLE IF NOT EXISTS "users" (
  "id" INT NOT NULL,
  "name" VARCHAR(255) NOT NULL,
  "active" BOOLEAN NOT NULL
);

INSERT INTO "users" ("id", "name", "active") VALUES (1, 'O''Neil', TRUE);

Frequently asked questions

Does it add a primary key?

No, because a JSON sample cannot tell which column is unique. Add PRIMARY KEY to the right column after generating the statement.

Are the INSERT values safe from SQL injection?

String values are escaped by doubling single quotes (and backslashes for MySQL). The output is intended for loading trusted data; in application code always use parameterised queries.

Can I generate only INSERT statements?

Yes — untick “CREATE TABLE”.

Is my data uploaded?

No. The SQL is generated in your browser.