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.
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:
- Rows — array of objects, one per inserted row, ready to drop into a mock API or seed file.
- Schema — column definitions (
{ name, type, nullable, default }) extracted from the CREATE TABLE, useful for building TypeScript types or form validators. - 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 snippetHide
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>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
- Paste your SQL into the input box. Multiple INSERT statements work; CREATE TABLE plus inserts in the same paste also works.
- Pick the output shape: Rows (just the data), Schema (just the columns), or Both (combined fixture format).
- Output regenerates live as you type or switch modes.
- Click Copy to grab JSON for clipboard, or Download to save a .json file.
- 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
Guides about this topic
- Developers & Technical · GuideHow to convert SQL to JSONConvert SQL to JSON online free with instant row-to-object mapping. Preserve types and handle NULLs accurately with no sign-up needed.
- Using Our Tools · GuideHow to generate QR codesMake QR codes for URLs, WiFi, vCard, or text. Learn error correction and sizing, then generate your QR code online free with no sign-up in seconds.
- Using Our Tools · GuideHow to create a strong passwordGenerate a strong password instantly online for free. Build high-entropy passphrases following NIST 2026 rules with no download needed.
- Developers & Technical · GuideHow to encode and decode Base64Understand the 3-to-4 mechanic and 33% overhead for standard, URL-safe, and MIME Base64. Free online reference to avoid common mistakes, no download needed.
- Design & Media · GuideHow to choose a color paletteBuild accessible color palettes using HSL theory, monochromatic to triadic schemes, WCAG contrast checks, and dark mode tips. Free, no-download guide.
- Developers & Technical · GuideHow to use JWT tokens securelyImplement secure JWT authentication by choosing RS256, setting expiration, using httpOnly cookies, and preventing 'alg: none' attacks in your browser for free.
Explore more developer utilities tools
- Port Number LookupSearch over 140 well-known TCP and UDP ports by number or service name. Free online reference tool with no sign-up, covering web, mail, DNS, and more.
- Test Credit Card NumbersReference table of canonical test card numbers from Stripe, Adyen, and Braintree sandbox docs. Plus Luhn validator + network detector.
- IPv6 Expander & ShortenerFormat IPv6 addresses to canonical form, handling zone IDs and prefixes, instantly online—free tool with no registration required.
- Htpasswd GeneratorCreate .htpasswd lines for Apache or nginx basic auth with browser-only SHA hashing instantly. Includes config snippets and a free online tool with no registration.
- Chmod CalculatorCalculate Unix file permissions: octal (755, 644) ↔ symbolic (rwxr-xr-x) ↔ rwx checkboxes. Covers setuid, setgid, sticky bit. With presets.
- Excel Formula ExplainerPaste any formula and get a plain-English breakdown of 60+ functions online free—no sign-up required, in your browser.