ToolJutsu
All tools
Developer Tools

SQL to JSON

Convert SQL INSERT statements into JSON.

0 chars

Paste one or more INSERT INTO statements above to see the JSON, or load the sample. The conversion runs entirely in your browser.

Processed on your device. We never see your files.

How to use SQL to JSON

What this tool does

This tool reads SQL INSERT INTO statements and turns the rows inside them into JSON. Paste one statement or many; for each one it parses the table name, the optional column list and every VALUES tuple, then emits a JSON array. When a statement names its columns, each row becomes an object keyed by column name. When it does not, each row becomes an array of values. The whole conversion runs in your browser — the SQL never leaves your machine.

Why you might need it

Database dumps, migration files and seed scripts are full of INSERT statements, but plenty of tools want JSON instead: a test fixture, a mock API response, a front-end data file, or input for another converter. Retyping rows by hand is slow and error-prone. Pasting the SQL you already have and copying clean JSON out is immediate. It is also a quick way to read a dense dump — JSON’s indentation makes the structure of each row far easier to scan than a long VALUES line.

How to use it

  1. Paste your SQL INSERT statements into the input box, or click Load sample to see the expected shape.
  2. The JSON output appears instantly below, pretty-printed with two-space indentation.
  3. Check the row count beside the output to confirm every tuple was picked up.
  4. Click Copy to put the JSON on your clipboard.
  5. If something is wrong, read the error message — it names the exact problem — fix the SQL, and the output refreshes.

Formats explained

A statement like INSERT INTO users (id, name) VALUES (1, 'Ada'), (2, 'Alan'); produces an array of two objects: {"id": 1, "name": "Ada"} and {"id": 2, "name": "Alan"}. The same statement without the (id, name) column list produces [1, "Ada"] and [2, "Alan"] instead, because the keys are unknown. Inside a value, NULL becomes null, TRUE and FALSE become booleans, bare numbers become JSON numbers, and single-quoted text becomes a string. An escaped quote — two single quotes in a row, as in 'O''Brien' — is decoded to the single character O'Brien.

Common pitfalls

The parser is quote-aware, so commas and parentheses inside a string literal are safe. The errors you are most likely to hit are structural: a string that was never closed, a VALUES list with a stray or missing parenthesis, or a row whose number of values does not match the number of named columns. Each of those produces a specific message rather than silently dropping data. Note that this is a focused INSERT converter, not a full SQL engine — SELECT, UPDATE, CREATE TABLE and similar statements are ignored, and database-specific functions used in place of a literal value are kept as plain text rather than evaluated.

Tips and advanced use

You can paste an entire seed file at once; comments are stripped automatically and every INSERT is collected into a single JSON array, which is handy for building one fixture from many statements. If you need objects rather than arrays, make sure each statement includes its column list. After converting, you can drop the JSON straight into a formatter or schema generator. And because the tool is fully client-side, converting INSERT statements pulled from a production database carries no risk of that data being transmitted anywhere.

Frequently asked questions

Is my SQL sent to a server?
No. The parsing and conversion run entirely in your browser using JavaScript. The SQL you paste is never uploaded, so it is safe to convert statements that contain internal data — you can confirm this in your browser's Network tab.
Which SQL statements does this tool understand?
It reads INSERT INTO statements of the form INSERT INTO table (colA, colB) VALUES (1, 'x'), (2, 'y'); It handles multiple statements at once, multiple value tuples per statement, and ignores line and block comments. Other statement types such as SELECT or CREATE TABLE are not converted.
What happens if my INSERT has no column list?
When a statement names columns, each row becomes a JSON object keyed by column name. When no column list is present, the tool cannot know the keys, so each row becomes a plain array of values in the order they appeared.
How are strings, NULL and booleans handled?
Single-quoted text becomes a JSON string, and an escaped quote written as two single quotes ('') is decoded to one quote. NULL becomes JSON null, TRUE and FALSE become booleans, and numeric literals become JSON numbers.
Why does my SQL show an error?
The most common causes are a missing closing quote, unbalanced parentheses in the VALUES list, or a row whose value count does not match the named columns. The error message names the specific problem so you can find it quickly.

Related tools