Export PostgreSQL to CSV
Dump files or
psql output.
Free PostgreSQL to CSV converter. Upload a pg_dump .sql file or paste psql query output — aligned table, pipe-separated or CSV format. Handles standard SQL quoting and all psql output modes. Runs in your browser.
Use these when you have direct database access — faster and simpler than this tool for large exports.
Two input modes — pick what you have available.
Upload a .sql file generated by pg_dump. CSVShift parses INSERT statements with PostgreSQL's standard quoting — double-quote identifiers, '' escaped strings, BOOLEAN values and NULL. Each row in the INSERT becomes a CSV row.
Copy output from any psql format and paste it here. CSVShift auto-detects the format: aligned table (default, with col | col2 and ----+---- separators), unaligned (-A flag), CSV output (\pset format csv), or tab-separated (-F '\t'). Footer lines like "(2 rows)" are stripped automatically.
Download the resulting CSV with UTF-8 BOM encoding, or copy to clipboard. Opens correctly in Excel, Google Sheets and any database import tool without encoding issues.
Common situations where a CSV export is necessary.
PostgreSQL query results that need pivot tables, charts or manual review in a spreadsheet — paste the psql output directly into CSVShift for instant conversion without needing server file access.
Exporting a PostgreSQL table as CSV for re-import into MySQL, SQLite or another system. CSV avoids SQL dialect incompatibilities in direct dump conversion.
Paste query output from a psql session, convert to CSV here, and share the spreadsheet with non-technical stakeholders who don't have database credentials.
Analyse a PostgreSQL backup's INSERT data in Excel to verify data integrity, check row counts, or audit specific values — without needing to restore the database.
Other free converters on CSVShift you might need.
PostgreSQL data parsed
in your browser. No upload.
CSVShift parses pg_dump files and psql output entirely in JavaScript. Your database data is never transmitted to any server. The parser handles PostgreSQL's standard SQL string escaping ('' not backslash) and correctly identifies NULL, BOOLEAN, NUMERIC and TEXT values.
\copy table TO 'file.csv' WITH (FORMAT csv, HEADER true); — writes to your local machine. For a browser-based option, run the query in psql, copy the output, switch to CLI Output mode in CSVShift and paste it.\copy (SELECT * FROM table) TO '/local/path/file.csv' WITH (FORMAT csv, HEADER true); — the backslash \copy writes to the file on your local machine, not the PostgreSQL server. Works with any remote or cloud PostgreSQL instance without needing server file system access.\copy (SELECT col1, col2 FROM table WHERE condition ORDER BY col1) TO 'file.csv' CSV HEADER;. Any valid SELECT query works as the source. Alternatively, use \pset format csv then run the query to get CSV output in the terminal.