JSON to SQL

  • 3 dialects
  • Type inference
  • Nothing uploaded

CREATE TABLE with inferred types, plus batched INSERTs for three dialects.

Input
SQL

Paste input on the left to see sql.

Everything runs in your browser — nothing is uploaded.

About to sql

Converting JSON to SQL produces a CREATE TABLE with column types inferred across every record, plus batched INSERT statements. JSONic supports PostgreSQL, MySQL and SQLite, widens a column to text when it holds mixed types, and marks a column nullable only where a null actually appears.

Getting a JSON fixture into a database usually means writing the schema by hand. This infers column types across every record — widening to text when a column holds mixed types, marking columns nullable only when a null actually appears — and emits a CREATE TABLE plus INSERT statements in PostgreSQL, MySQL or SQLite syntax. Large arrays are batched rather than emitted as one enormous statement.

Questions

How are column types inferred?

By widening across all records: integers stay integer only if no record has a decimal, and any string in the column makes the whole column text. Nested objects and arrays become JSONB, JSON or TEXT depending on dialect.

Is the output safe against SQL injection?

String literals are escaped by doubling single quotes, which is correct for literal values in all three dialects. It is still generated SQL from untrusted input — review it before running it against anything that matters, and prefer parameterised inserts for production loading.

Why are INSERTs split into batches?

A single INSERT with a hundred thousand rows exceeds server packet limits and is painful to debug. Statements are chunked at 1000 rows, which every dialect handles comfortably.