Navigation

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

  1. Open the JSON Convert tool.
  2. Select SQL from the Database category in the format grid.
  3. Provide your JSON array in the input area (paste or upload a file).
  4. The tool will automatically use the file name as the table name (e.g., users.json โ†’ INSERT INTO users ...).
  5. 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.