Convert JSON to SQL
Generate SQL INSERT statements from JSON arrays to easily import data into relational databases like PostgreSQL, MySQL, or SQLite.
Last updated:
Moving data from a JSON API or document store into a relational database requires converting objects into rows and columns. DataLensia automates the generation of SQL INSERT statements.
๐ฉ The Problem
You have a JSON array:
[
{"id": 1, "name": "Admin", "role": "superuser"},
{"id": 2, "name": "Editor", "role": "staff"}
]
You need to import this into an existing SQL table:
INSERT INTO users (id, name, role) VALUES (1, 'Admin', 'superuser');
INSERT INTO users (id, name, role) VALUES (2, 'Editor', 'staff');
๐ ๏ธ How to Generate SQL in DataLensia
- Open the JSON Convert tool.
- Select SQL from the Database category in the format grid.
- Provide your JSON array in the input area (paste or upload a file).
- The tool will automatically use the file name as the table name (e.g.,
users.jsonโINSERT INTO users ...). - Preview the generated SQL instantly, then copy or download.
๐ก Advanced: Complex JSON
If your JSON is nested, first use the Flatten Recipe or the Transform Builder to create a flat structure before generating SQL.
๐ Try it now
Generate SQL scripts from your JSON data using the Data Converter.