JSON to SQL converter
Paste a JSON array and get a CREATE TABLE statement and INSERT statements for your database, with nested values kept in JSON columns. Everything runs in your browser.
How to convert JSON to SQL
- Paste a JSON array of objects, such as an API response, a MongoDB export, or a fixtures file, into the input panel.
- Pick the dialect of the database you're loading into and type the table name. Outside SQLite, a schema-qualified name such as
staging.ordersworks too. - Check the inferred column types in the CREATE TABLE statement, or turn it off if the table already exists.
- Copy the SQL or download it as a
.sqlfile and run it against your database.
For example, the object {"id": 5003, "customer": "Initech's lab", "shipping": null} becomes:
INSERT INTO orders (id, customer, shipping)
VALUES (5003, 'Initech''s lab', NULL);How JSON maps to tables
Each object in the array becomes a row, and each key becomes a column. Keys that appear in only some objects still get a column, with NULL in the rows that don't have them. Column types come from the JSON values: numbers, booleans, and ISO date strings get matching SQL types, and everything else is text.
Nested objects and arrays stay together in one JSON column rather than being split into child tables, which keeps one INSERT per row and lets you query nested fields later with your database's JSON functions.
When to convert JSON to SQL
- Loading an API response or webhook payload into a database table
- Moving documents from MongoDB, Firestore, or DynamoDB exports into a relational database
- Writing seed data or fixtures for a migration or test database
- Turning a JSON config or lookup list into a table you can join against
- Sharing a dataset as a single SQL script that recreates the table
From JSON to answers
Once your data is in a database, Basedash lets you ask questions about it in plain English. It writes the SQL, runs it, and returns a chart or dashboard, and it connects to PostgreSQL, MySQL, BigQuery, Snowflake, and 750+ other data sources.
FAQ
How do I convert JSON to SQL INSERT statements?
Paste a JSON array of objects into the input panel, such as an API response or an export from a NoSQL database. Choose the SQL dialect and a table name. Each object becomes one row and each key becomes a column, and the converter writes a CREATE TABLE statement followed by INSERT statements as you type. Copy the SQL or download it as a .sql file and run it against your database.
What JSON structure does the converter accept?
A top-level array of objects, like [{"id": 1}, {"id": 2}], or a single object, which becomes one row. If your data is wrapped in an envelope such as {"data": [...]}, paste only the inner array. Arrays of plain values, such as [1, 2, 3], have no column names, so the converter shows an error asking for objects instead. Invalid JSON shows the parser's error message so you can find the problem.
What happens to nested objects and arrays?
Nested objects and arrays are kept whole in a JSON column: JSONB in PostgreSQL, JSON in MySQL, NVARCHAR(MAX) in SQL Server, and TEXT in SQLite, where the JSON functions read text. The value is written as a JSON string literal, so you can query it later with operators like ->> in PostgreSQL or JSON_VALUE in SQL Server. To get one column per nested field instead, flatten the JSON before converting it.
How are JSON types mapped to SQL column types?
JSON numbers become INTEGER, BIGINT for values outside the 32-bit range, or NUMERIC and DECIMAL when any value has decimals. Booleans become BOOLEAN, or BIT and INTEGER in SQL Server and SQLite. Strings become text, except ISO dates and timestamps such as 2026-10-01 or 2026-10-01T14:32:00Z, which become DATE, TIMESTAMP, or TIMESTAMPTZ columns where the dialect has them. Numeric strings like "42" stay text because JSON already marks them as strings.
What if the objects have different keys?
The converter collects every key that appears in any object, in the order it first sees them, and creates one column for each. When an object doesn't have a key, its value is written as NULL. A JSON null is also written as NULL. Column types are chosen from the values that are present, so a key that is missing from most rows still gets the right type from the rows that have it.
Is my JSON sent to a server?
No. Parsing and SQL generation run entirely in your browser with JavaScript, so API responses, customer records, and exports never leave your machine. Nothing is logged or stored, and the page keeps working offline once it has loaded. Inputs of a few megabytes convert comfortably in a modern browser.
Skip the import and ask your data
Connect your data and describe what you want to see. Basedash handles the query, visualization, and dashboard.