Export a PostgreSQL table to JSON

/ / export a postgresql table to json

Updated: 2017-04-22

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;

That’s all there is to it :)