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 column | MySQL | PostgreSQL | SQLite |
|---|---|---|---|
| whole numbers | INT / BIGINT | INT / BIGINT | INTEGER |
| decimals | DOUBLE | DOUBLE PRECISION | REAL |
| true / false | BOOLEAN | BOOLEAN | INTEGER (0/1) |
| text up to 255 chars | VARCHAR(255) | VARCHAR(255) | TEXT |
| longer text | TEXT | TEXT | TEXT |
| objects / arrays | JSON | JSONB | TEXT |
How to use it
- Paste a JSON array of objects (a single object also works).
- Set the table name and SQL dialect.
- Review the generated column types — add primary keys, indexes or tighter
VARCHARlengths as needed — then copy or download the.sqlfile.
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.