SQL to JSON

Convert a database client result table to JSON

Runs in your browserUtility02Converters

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

  1. 1Copy the whole result table out of your client and paste it here. The +---+ separator lines are fine to leave in.
  2. 2Review the resulting array of objects.
  3. 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 tools