Why Convert Between SQL and JSON?
In microservice development and database migrations, developers routinely extract records from SQL dumps into test fixture JSON files, or transform scraped JSON payloads into bulk SQL INSERT commands for MySQL and PostgreSQL.
Safe Quote Escaping
- SQL String Escaping: String literals with single quotes (e.g.
O'Reilly) are automatically escaped to standard SQL syntax. - Null & Boolean Fidelity:
NULL、TRUE、FALSECorrectly preserves native null and boolean types.
Under the hood
splitSql() is a small scanner rather than a regex: it walks the statement tracking quote state and parenthesis depth, so a semicolon inside a string literal or inside a nested call does not end the statement. splitSqlValues() does the same job for the VALUES tuples, and parseSqlVal() decides the type of each literal — quoted text, integer, decimal, NULL or boolean. sqlToJson() assembles the rows into objects keyed by the column list, and jsonToSql() walks the reverse path, quoting identifiers with backticks and escaping single quotes inside values.
Formats, sizes and other limits
Only INSERT INTO ... VALUES and its inverse are understood. SELECT, UPDATE, CREATE TABLE, stored procedures and multi-table joins are not parsed at all, and a value produced by a function call or an expression cannot be evaluated, so it reports an error instead of guessing. Large integers lose precision once they exceed JavaScript's safe range, timezone information in datetime literals is dropped, and binary columns come back as text.
Privacy: nothing is uploaded
Statements are scanned and converted as strings inside this tab. No database connection is opened and nothing is sent, which also means the tool cannot verify that your SQL would run.
Frequently asked questions
Can it convert a query result?
No — only INSERT statements and JSON arrays. A SELECT has no literal data to extract, so there is nothing to convert without a database.
Why does my statement fail to parse?
Most often it contains a function call, an expression, or a dialect-specific escape the scanner does not model. Simplify the VALUES to plain literals and it will parse.
Will Chinese text survive the round trip?
Yes, on a UTF-8 page. The text is handled as JavaScript strings, so escaping is preserved as long as you keep the file encoding consistent.