YamlBox

Code generators

JSON to SQL Generator

Turn a JSON dataset into a runnable SQL script: a CREATE TABLE with inferred column types plus INSERT statements, in PostgreSQL, MySQL or SQLite dialect.

Options

JSON array

Examples: Products · Users — ⌘/Ctrl + Enter converts · drop a file to load it · processed locally

SQL script

Output is read-only. Use Copy, Download or Share to move it out.

How to use the json to sql tool

  1. Paste a JSON array

    Each array item becomes one row. A single object is treated as a one-row table.

  2. Pick dialect and table name

    Choose PostgreSQL, MySQL or SQLite and name the table. Types map per dialect — nested objects become JSONB, JSON or TEXT accordingly.

  3. Run the script

    Copy into psql, the MySQL CLI or sqlite3. Values are safely quoted, so strings containing apostrophes do not break the script.

What makes this one different

  • Dialect-aware types: JSONB for Postgres, JSON for MySQL, TEXT for SQLite
  • Integer vs numeric detection from real values, and TIMESTAMPTZ/TEXT/DBL for date-looking strings
  • Proper single-quote escaping — no SQL injection through sample data
  • NULL for nulls; booleans as TRUE/FALSE (or 1/0 for SQLite)
  • Multi-row INSERTs by default, or one statement per row

Privacy by architecture: this page contains no analytics that receive your input, and the conversion code runs in your tab. You can disconnect from the network after loading and keep working.

JSON to SQL — frequently asked questions

How are column types chosen?

Each column is scanned across all rows. All integers become INTEGER/INT, any decimal becomes NUMERIC/DOUBLE, booleans become BOOLEAN, JSON-looking strings become TIMESTAMPTZ, and nested objects or arrays become JSONB/JSON/TEXT depending on the dialect.

Is the generated SQL safe to run?

It is a plain script with correctly escaped string literals, so it is safe as a starting point. Review it before running on production: you may want primary keys, indexes, NOT NULL constraints and foreign keys that the generator cannot infer.

What about nested objects?

They become a single JSON/JSONB/TEXT column holding the nested value. Relational modelling of nested structures is a design decision, so the generator does not guess joins for you.

Which dialect should I choose?

PostgreSQL if you want JSONB and TIMESTAMPTZ, MySQL for JSON columns with DOUBLE numerics, SQLite for file-based databases and tests. The structure of the script is identical; only type names and boolean literals change.

Searching for “json to sql insert”, “create table from json”, “json to postgres”? You are in the right place — browse all 19 tools.

Deeper reading

Blog · 5 min read JSON to SQL: from a payload to a table you can query Convert JSON to SQL with CREATE TABLE and INSERT statements generated from a real payload, with sensible type mapping, escaping and honest limits. Read the guide →