What is SQL to JSON?
This SQL result set to JSON converter parses the ASCII tables printed by command-line clients such as mysql and psql, builds an array of objects from the header row, converts purely numeric columns to numbers, and maps NULL to null. Parsing runs entirely in your browser.
How to use SQL to JSON
- 1Copy the whole result table out of your client and paste it here. The +---+ separator lines are fine to leave in.
- 2Review the resulting array of objects.
- 3Copy the JSON to write test cases or build mock data.
Frequently asked questions
Which client output formats are supported?+
Any pipe-delimited table whose first row is the header, which covers the default output of mysql, mariadb, and psql. For tab-separated output such as mysql -B, use the CSV to JSON tool with the tab delimiter instead.
Will a value containing a pipe character break the parsing?+
Yes. ASCII tables use the pipe as their column separator, so a pipe inside a value is indistinguishable from a real delimiter. For data like that, export JSON directly from the database with MySQL JSON_OBJECT or psql \gx rather than parsing the printed table.
Related tools
All toolsJSON to YAML Converter
Convert JSON to YAML while preserving the nesting
YAML to JSON Converter
Convert YAML to JSON, multi-document files included
JSON to CSV Converter
Convert a JSON array of objects to CSV, with nested fields flattened automatically
CSV to JSON Converter
Convert CSV to JSON with automatic header and delimiter handling
JSON to TypeScript
Infer TypeScript type definitions from JSON
JSON to Go Struct
Convert JSON to Go structs with json tags filled in