JSON to SQL converter

Convert a JSON array into CREATE TABLE and INSERT statements for PostgreSQL, MySQL, SQL Server or SQLite. Nested keys flattened. Nothing is uploaded.

About this converter

You captured an API response and now you want it in a table - to query it properly, to seed a test database, or to diff it against what your own system produced. JSON and relational tables are not the same shape, so something has to give, and this tool makes those decisions explicitly rather than silently.

Objects in the array become rows. Nested objects are flattened into underscore-separated columns, so a city inside an address inside a user becomes address_city. Arrays are stored as JSON text in a single cell rather than exploded into extra rows, which keeps your row count equal to your record count - almost always what you want when the array is a list of tags or ids.

Records with different keys are handled by taking the union of every key across every object. A field present on only some records still gets its own column, and the records missing it get NULL rather than being dropped. The converter tells you when this happened, because a column that is NULL for most rows is usually a sign your data is more heterogeneous than you assumed.

Column types are inferred conservatively. Whole numbers become BIGINT, decimals become DOUBLE PRECISION or REAL, true and false become BOOLEAN or BIT depending on the dialect, and anything ambiguous widens to text. Identifiers are quoted for the target dialect so a field called order or group does not become a syntax error.

As always, generated SQL is for a migration or seed file you will read first, not a replacement for parameterised queries. The output says so in a header comment. And the conversion runs in your browser, so an API response containing real user data stays on your machine.

Frequently asked questions

What happens to nested arrays?
They are stored as JSON text in one cell. If you need them as rows, split the JSON into one array per table first and convert each separately.
My records have different fields. Will columns be lost?
No. Every key across every record becomes a column, and records missing it get NULL. The converter notes when this happened.
Which dialect should I pick for Postgres?
ANSI / PostgreSQL. It uses double-quoted identifiers, TRUE and FALSE literals, and DOUBLE PRECISION - all correct for Postgres.

Related converters