Export a PostgreSQL table to JSON

/ / export a postgresql table to json

Updated: April 22, 2017


Run the psql command in your terminal, and then input the following:

\t
\a
\o filename.json
SELECT row_to_json(r) FROM your_table AS r;