CodingDevTools

Turn a JSON array into SQL INSERT rows

Every export you get from an API, a NoSQL store, or an analytics tool arrives as the same shape: an array of objects in a .json file. Your database, meanwhile, wants INSERT statements. json2sql reads that array and emits one INSERT row per element - strings, numbers, booleans, and nulls typed automatically - in PostgreSQL, MySQL, or SQLite dialect. No throwaway conversion script required.

Last updated: 2026-08-23 · json2sql on GitHub

Honest scope: json2sql is a one-way converter: JSON in, a file of INSERT statements out. It does not connect to your database or execute anything - you load the generated SQL yourself or pipe it through your usual migration step. Nested objects are supported via --flatten, which splits them into separate relational tables.

Install

# not on public PyPI - install from source pip install git+https://github.com/Coding-Dev-Tools/json2sql.git # also available via Homebrew (macOS/Linux): brew tap Coding-Dev-Tools/tap && brew install json2sql-cli # or Scoop (Windows): scoop bucket add Coding-Dev-Tools https://github.com/Coding-Dev-Tools/scoop-bucket scoop install json2sql-cli

A bare pip install json2sql will NOT get this tool - it is not on public PyPI, and the suite's self-hosted package index is currently offline. The git+ command and the Homebrew/Scoop packages above are the verified working installs (package links checked 2026-08-23).

From array-of-objects to INSERT rows

The feature that matters for seed files and data migrations is the boring one: json2sql handles a JSON array of objects as multiple INSERT rows - one statement per element, with each value's type (string, number, boolean, null) inferred automatically. Point it at your table name so the generated SQL is valid the moment it lands:

json2sql convert users.json --table users

# pick the dialect that matches your target database:
json2sql convert users.json --dialect postgres
json2sql convert users.json --dialect mysql
json2sql convert users.json --dialect sqlite

# write straight to a seed file instead of stdout:
json2sql convert fixtures.json --dialect sqlite -o seed.sql

Pipe it into your pipeline

Because the CLI reads stdin too, conversion drops into a shell pipeline without a temp file - useful when the JSON comes from curl, jq, or another build step:

cat data.json | json2sql convert --dialect postgres --table events > events.sql

And for test fixtures in CI, generate a seed file and load it into a scratch SQLite database:

json2sql convert fixtures.json --dialect sqlite -o seed.sql
sqlite3 test.db < seed.sql

Nested objects? Flatten them into real tables

Real exports are rarely flat. With --flatten, json2sql splits nested objects into separate relational tables instead of mangling them into stringified blobs. The full walkthrough - including how the split tables come back together - is in the companion guide, nested JSON to relational SQL.

What free vs paid gets you

Free ($0)Individual ($9/mo)
Convert + pipe CLI (all three dialects)YesYes
Rows per conversionLimitedUnlimited
Batch processingNoYes
Schema generationNoYes
Works offline, no telemetryYesYes

Individual is $9/mo ($7/mo billed annually). A $49/mo Suite license covers all eleven tools in the family - schema migration, config drift, env security, infra plans, dead code, and more.

Frequently asked questions

Is json2sql on public PyPI?

No. The verified working installs are pip install git+https://github.com/Coding-Dev-Tools/json2sql.git, Homebrew (brew install json2sql-cli after tapping Coding-Dev-Tools/tap), and Scoop (scoop install json2sql-cli).

Does each array element become its own INSERT row?

Yes - a JSON array of objects is handled as multiple INSERT rows, with types inferred per value (strings, numbers, booleans, nulls).

Which SQL dialects are supported?

PostgreSQL, MySQL, and SQLite INSERT syntax, selected with --dialect.

What about nested objects?

Use --flatten: nested objects are split into separate relational tables rather than being flattened into opaque columns.

What does the free tier include?

The full CLI: convert and pipe across all three dialects, with limited rows per conversion. It works fully offline with no telemetry. Individual ($9/mo) lifts the row limit and adds batch processing plus schema generation.

Convert your next JSON export in one command

json2sql turns arrays of objects into typed INSERT statements for PostgreSQL, MySQL, and SQLite - free CLI tier, fully offline, no telemetry.

Try json2sql free →