Is there a way to convert a Postgres dump file to a text file?

I'm experiencing issues getting the dump to the proper file location of I would just restore from the dump file and then export to text.

Really I just need to import it into a SQLite database.

I think it's a binary dump. Here's what latest dump looks like:

enter image description here


1 Answer 1


This is a dump file produced by pg_dump -Fc. The dump may or may not contain the data depending on the options it was made with.

To create a text file containing SQL commands from it, use pg_restore.

The basic syntax is pg_restore -f output.sql file.dump, that is, you don't specify a target database (notice the missing-d option). -f- may be used instead of -f output.sql to send the SQL script to the standard output.

  • 1
    You have to specify the original dump file using the -f flag otherwise pg_restore will complain: pg_restore: error: one of -d/--dbname and -f/--file must be specified.
    – s.k
    Commented Jun 17, 2021 at 9:11
  • 1
    @s.k: on newer versions, yes. I've edited the answer to conform to both pre-v12 and post-v12 versions of pg_restore. Commented Jun 17, 2021 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.