SQL to JSON Converter (INSERT … VALUES)

Convert SQL INSERT statements to JSON: multi-row VALUES, quoted identifiers, escaped quotes, NULL, TRUE/FALSE and numbers, across several tables. Free.

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is SQL to JSON?

Paste SQL containing INSERT statements – a database dump, seed file or migration – and get the rows as JSON. Each row becomes an object keyed by column name; inserts into several tables produce an object with one array per table.

How to use SQL to JSON

  1. Paste SQL into the SQL input box, or use Load sample or Open file.
  2. Keep Backslash escapes in strings (MySQL) on for MySQL dumps, or turn it off for standard SQL / PostgreSQL.
  3. Choose the JSON Indentation.
  4. The JSON output updates as you type; use Copy or Download.

Example

Input
INSERT INTO users (id, name) VALUES (1, 'O''Brien'), (2, NULL);
Output
[
  {
    "id": 1,
    "name": "O'Brien"
  },
  {
    "id": 2,
    "name": null
  }
]

When to use SQL to JSON

Use it to extract data from SQL dumps or seed files without running a database. It does not execute SQL: SELECT, UPDATE and DDL statements are ignored, and functions are not evaluated.

How SQL to JSON works

A tokenizer reads strings ('' doubled quotes, optional MySQL backslash escapes, N'…' and E'…' prefixes), quoted identifiers ("…", backticks, […]), numbers and comments (--, #, /* */). The parser then looks for INSERT [IGNORE] INTO table [(columns)] VALUES (…), (…) and skips every other statement. NULL, TRUE and FALSE map to JSON null and booleans; integers too large for JavaScript are kept exactly. Expressions such as NOW() are kept as their source text. Rows without a column list get keys column1, column2, …

Common Use Cases

  • Turn a mysqldump excerpt into JSON fixtures
  • Inspect seed data from a migration file
  • Move a few rows from SQL into a NoSQL store
  • Check which values an INSERT statement really contains

FAQs

Which SQL dialects work?

The INSERT syntax of MySQL/MariaDB, PostgreSQL, SQLite and SQL Server: all their identifier quoting styles are recognized. Switch off backslash escapes for non-MySQL dumps containing Windows paths.

What about INSERT … SELECT?

Only VALUES lists contain literal data; INSERT … SELECT statements are skipped.

Why is NOW() a string?

The tool does not run SQL, so expressions are kept as their source text.

Good next steps

Explore more categories