Reads MySQL/MariaDB INSERT statements and turns each row into an object in a JSON array. If a CREATE TABLE statement is included in the same input, its column names and types are used, so TINYINT(1) values become true/false and JSON columns are expanded into objects.
Made for moving part of a mysqldump file, a migration seed, or INSERT statements attached to a bug report into test fixtures or API mocks.
SQL box. For the INSERT INTO t VALUES ... form without a column list, include that table's CREATE TABLE statement too.--, #, /* */) and other statements like SET or LOCK TABLES can stay; they are skipped.Result. If no INSERT is found, you get No INSERT statement found.CREATE TABLE `products` (
`id` INT NOT NULL,
`name` VARCHAR(100),
`on_sale` TINYINT(1),
`attrs` JSON
);
INSERT INTO `products` VALUES
(1, 'Desk lamp', 1, '{"color":"white"}'),
(2, 'Kid''s chair', 0, NULL);[
{
"id": 1,
"name": "Desk lamp",
"on_sale": true,
"attrs": {
"color": "white"
}
},
{
"id": 2,
"name": "Kid's chair",
"on_sale": false,
"attrs": null
}
]The INSERT has no column list, so the column order comes from the CREATE TABLE before it. 1/0 in the TINYINT(1) column on_sale became booleans, the string in the JSON column attrs became an object, and the quote escaped as '' was read correctly.
INSERT, INSERT IGNORE, REPLACE INTO, and multi-row VALUES (...), (...).'text' and "text" → strings, NULL → null, TRUE/FALSE → booleans. Function calls like NOW() are kept as the raw text "NOW()".'', \', \n, \t and so on) are decoded.CREATE TABLE, its column order is used, 0/1 in TINYINT(1), BOOL or BOOLEAN columns become booleans, and JSON column strings become objects.CREATE TABLE, keys are named column1, column2 and so on.{ "table": [...] }. db.table and [dbo].[table] are reduced to the table name.Cut the few rows needed to reproduce a bug out of a production dump, convert them, and use the JSON as unit-test input or Storybook mock data.
In a long single-line INSERT ... VALUES, counting which value lands in which column is error-prone. As JSON, every value sits next to its column name, so ordering mistakes stand out.
INSERT ... SELECT, UPDATE and DELETE are not read.DECIMAL (12.10 → 12.1) and BIGINT values beyond 2^53 lose precision.N'...' Unicode prefix and PostgreSQL's E'...' escape strings are read as ordinary strings, so N'서울' becomes "서울".CREATE TABLE, 0/1 in TINYINT(1) columns stay numbers.Yes. Only INSERT and CREATE TABLE statements are read and everything else is skipped. Very large files can slow the browser, though, so pasting just the tables you need is better.
Yes for the usual dump format. E'...' strings are understood, and :: casts are read and applied: '{"a":1}'::jsonb becomes an object, '5'::int a number, 't'::boolean true. Other casts such as ::timestamp or ::uuid just keep the string value.
Feed it to the JSON to MySQL tool, which infers types and regenerates CREATE TABLE and INSERT. It won't necessarily match the original table definition, so review the types.