Skip to main content
7BBusyBoss

SQL to JSON Converter — INSERT Statements → JSON Array

Convert SQL INSERT statements to JSON arrays. Supports multiple rows, NULL values, and MySQL/PostgreSQL/SQL Server quoting styles.

No limitsZero data leaksSuper fast

SQL INSERT to JSON Converter

Files never leave your browser
View:

0 lines · 0 chars · 0 B

0 lines · 0 chars · 0 B

You're on 7BusyBoss — 300+ free tools that run instantly in your browser. No signup, nothing uploaded.

Browse all Code Converters
About this tool

This parser handles INSERT statements only

Worth saying first so nobody wastes time: this converts INSERT INTO table (col1, col2) VALUES (v1, v2), (v3, v4); into a JSON array of row objects, and nothing else. A SELECT, a CREATE TABLE, an ALTER or a stored procedure will be rejected with the message Each statement must look like: INSERT INTO table (col1, col2) VALUES (v1, v2);

That narrowness is deliberate. It is built for turning seed data, fixtures and small extracts into test data, which is the case where copying a few INSERT statements out of a file is genuinely quicker than anything else. For a real production dump, do not fight the parser — every major database can export a query result directly as JSON or CSV, and that route handles schemas, types and volume properly.

Column and string quoting matches your database's dialect

Each major database quotes identifiers differently, and all three styles are accepted and stripped:

  • MySQL backticks — INSERT INTO users (`id`, `name`) VALUES (1, 'Ada');
  • PostgreSQL double quotes — INSERT INTO users ("id", "name") VALUES (1, 'Ada');
  • SQL Server square brackets — INSERT INTO users ([id], [name]) VALUES (1, 'Ada');

All three produce identical JSON keys, unquoted. Unquoted identifiers work too, so a hand-written statement needs no decoration.

String values may use single or double quotes, and a quote inside a string is escaped by doubling it — the SQL convention rather than the backslash escaping most programming languages use. Both 'It''s working' and "It""s working" produce the JSON string It's working.

NULL, numbers and booleans become native JSON types

This is the detail that decides whether the output is usable data or a wall of strings, so it is worth being exact:

  • Unquoted NULL, in any case, becomes JSON null — not the string "NULL". A quoted 'NULL' stays the literal string, which is the correct distinction and one many converters get wrong.
  • A bare number such as 42 or 3.14 becomes a JSON number, so a count of zero is 0 rather than "0".
  • Unquoted TRUE and FALSE, in any case, become JSON booleans.

The practical value is that the result drops straight into a test fixture or a seed script without a cleanup pass — comparisons behave, empty values are genuinely null, and nothing needs re-parsing.

Formatting is flexible; column counts are not

You can paste a single INSERT or a whole run of them separated by semicolons, and a trailing semicolon on the last statement is optional. Rows may sit on one line or spread across many, since parentheses are matched rather than lines counted, so pasting a formatted file works unchanged.

The one thing that must line up is arity. If a row supplies a different number of values than there are columns, you get Row has X values but Y columns. with the actual figures — usually a missed comma, or a comma inside an unquoted value splitting one field into two.

Rows converted to JSON are often headed for a spreadsheet rather than code, and JSON is the wrong shape for that. The JSON to Markdown table converter flattens it into something readable instead.

How to use the SQL INSERT to JSON Converter

Takes about a minute. No signup, no download, your data stays in your browser.

  1. 1
    Open the tool. Scroll up to the SQL INSERT to JSON Converter above — it loads instantly in your browser, no install needed.
  2. 2
    Enter your values. The fields come pre-filled with realistic defaults so you can see how it works — replace them with your own numbers.
  3. 3
    Read the result. The output updates instantly. Copy or share it — nothing is uploaded to a server, everything stays on your device.

Frequently asked questions

Common questions about the SQL INSERT to JSON Converter.

Can I use this with SELECT statements or a full database dump?

No. It parses only INSERT statements of the form INSERT INTO table (columns) VALUES (values). SELECT, CREATE TABLE, ALTER, DROP and anything else are rejected. For a full export, run a query in your database and export the result as JSON or CSV directly — every major database supports that and it handles schema and volume properly.

What if a string value contains a quote?

Double it, which is the SQL convention rather than the backslash escaping most languages use. In a single-quoted string write two single quotes, and in a double-quoted string write two double quotes. Both forms produce the same JSON string with one literal quote in it.

Does NULL become JSON null or the string NULL?

Unquoted NULL becomes JSON null, in any capitalisation. A quoted value stays the literal string NULL. That distinction is the point — it means an empty column arrives as a real null your code can test for, rather than a string that quietly passes every truthiness check.

Are trailing semicolons required, and can I paste several statements?

Multiple statements are fine, separated by semicolons, and the semicolon after the last one is optional. Formatting does not matter either, since parentheses are matched rather than lines counted, so a statement spread over several lines parses the same as one written on a single line.

What does the error about values and columns mean?

It means one row supplied a different number of values than the column list declared, and the message gives both counts. The usual causes are a missing comma between values, or a comma inside a value that was not quoted, which splits a single field into two. Compare the row it names against your column list.

Community rating

Discussion (0)

No comments yet. Start the discussion.