Skip to content
Free Tool Arena

Developer Utilities · Free tool

SQL to JSON

Parse SQL INSERT statements and export rows as JSON. Handles quoted strings, nulls, and numeric types. Free online tool converts instantly in your browser — no sign‑up.

Updated June 2026
Parsed 3 rows
Found this useful?EmailBuy Me a Coffee

Advertisement

What it does

Paste a SQL CREATE TABLE definition or a collection of INSERT INTO ... VALUES (...) statements and get structured JSON back. Three output modes:

  1. Rows — array of objects, one per inserted row, ready to drop into a mock API or seed file.
  2. Schema — column definitions ({ name, type, nullable, default }) extracted from the CREATE TABLE, useful for building TypeScript types or form validators.
  3. Both — schema plus rows in a single envelope, suitable for fixtures or for piping to a code generator.

Common uses: migrating fixture data from an SQL dump to a NoSQL store (paste your INSERTs, get JSON, paste into MongoDB / Firestore / DynamoDB); mocking an API from a database schema before the back-end is built; generating TypeScript types by exporting the schema and feeding it through json-to-typescript; seeding a JS test framework (Vitest / Jest fixtures) from an existing SQL test fixture file.

The parser handles standard ANSI SQL — most PostgreSQL, MySQL, SQLite, and SQL Server dump formats parse cleanly. It's a best-effort lightweight parser, not a full SQL engine: complex syntax (window functions, CTEs, stored procedures, vendor-specific extensions) won't parse. Stick to plain CREATE TABLE / INSERT for reliable output.

Embed this tool on your siteShow snippet

Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.

<iframe src="https://freetoolarena.com/embed/sql-to-json" width="100%" height="720" frameborder="0" loading="lazy" title="SQL to JSON" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>
Embed docs →

Example input & output

Input

CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL,
  age INTEGER
);
INSERT INTO users VALUES (1, 'a@example.com', 28);
INSERT INTO users VALUES (2, 'b@example.com', NULL);

Output

{
  "schema": [
    {"name": "id", "type": "integer", "nullable": false, "primaryKey": true},
    {"name": "email", "type": "text", "nullable": false},
    {"name": "age", "type": "integer", "nullable": true}
  ],
  "rows": [
    {"id": 1, "email": "a@example.com", "age": 28},
    {"id": 2, "email": "b@example.com", "age": null}
  ]
}

SQL NULL becomes JSON null. Column types stay close to SQL spelling (integer, text, varchar) so downstream code can map them to language-specific types as needed.

How to use it

  1. Paste your SQL into the input box. Multiple INSERT statements work; CREATE TABLE plus inserts in the same paste also works.
  2. Pick the output shape: Rows (just the data), Schema (just the columns), or Both (combined fixture format).
  3. Output regenerates live as you type or switch modes.
  4. Click Copy to grab JSON for clipboard, or Download to save a .json file.
  5. If parsing fails, simplify the SQL: remove vendor-specific extensions (auto-generated columns, CHECK constraints, triggers) and try just plain CREATE TABLE / INSERT.

When to use this tool

  • Migrating fixture data from a SQL dump into MongoDB, Firestore, DynamoDB, or any NoSQL store.
  • Building a mock API from an existing database schema before the backend is ready.
  • Generating TypeScript interfaces from a CREATE TABLE definition (export schema → run through json-to-typescript).
  • Seeding test fixtures for JavaScript test frameworks (Vitest, Jest) when you only have SQL fixtures available.

When not to use it

  • Migrating production data — this is fine for fixtures and mocks, not a replacement for proper ETL tools that handle constraints, indexes, foreign keys, triggers.
  • Vendor-specific SQL features (Postgres window functions, MySQL JSON functions, SQL Server T-SQL) — the parser is plain ANSI SQL only.
  • Stored procedures, triggers, views — those don't have a clean JSON representation; this tool ignores them.
  • Performance-sensitive imports — the parser runs in-browser and isn't optimized for multi-million row dumps. Use a CLI tool (sql-to-json npm package, mysqldump-to-json) for those.

Frequently asked questions

Which SQL dialects are supported?
ANSI SQL (the standard) plus the most common syntax found in PostgreSQL, MySQL, SQLite, and SQL Server dumps. Vendor-specific extensions — JSONB, AUTO_INCREMENT, IDENTITY, T-SQL extensions — partially work depending on syntax. For best results, use plain CREATE TABLE and INSERT.
How does it handle quoted identifiers and strings?
Double-quoted identifiers ("column_name") and single-quoted strings ('value') are both recognized. Backtick-quoted identifiers (MySQL style) are also accepted. Inside string values, escape characters (' as '' or \') are decoded.
What about INSERT with column lists?
Both forms work: `INSERT INTO t VALUES (...)` (positional, requires CREATE TABLE in the same paste so column order is known) and `INSERT INTO t (col1, col2) VALUES (...)` (explicit column names). The latter is preferred because it doesn't depend on knowing the schema.
How are SQL dates/timestamps converted?
Kept as ISO-8601 strings in the JSON output. SQL `DATE '2026-04-23'` becomes `"2026-04-23"`; SQL `TIMESTAMP '2026-04-23 14:30:00'` becomes `"2026-04-23T14:30:00"`. JS code can parse them with `new Date()`.
Will it deduplicate identical rows?
No — every INSERT becomes one JSON object. If your SQL has duplicate rows (which a real database with PRIMARY KEY would reject), the JSON also has duplicates. Filter them in your code if it matters.

Advertisement

Learn more

Explore more developer utilities tools

100% in-browserNo downloadsNo sign-upMalware-freeHow we keep this safe →

Found this useful?

The tools stay free thanks to readers who chip in or spread the word.

Buy Me a Coffee