- pgAdmin exports to CSV or delimited text, not to .xlsx; open the CSV in Excel.
- Quickest route: run the query in the Query Tool and click Save results to file (F8) to save the result set as CSV.
- For a few rows, select them in the Data Output grid and use Copy with headers, then paste into a spreadsheet.
- For large or scheduled exports, use Tools > Export Data Using Query... or the Import/Export Data dialog, which run as background processes.
Can pgAdmin export to Excel?
Not as an Excel workbook. The pgAdmin documentation describes only delimited text output: the Query Tool saves a result set as a delimited text file, CSV if the separator is a comma, and the export dialogs write binary, csv or text files. A CSV opens in Excel and other spreadsheet programs, so the practical answer to "pgAdmin export to Excel" is to export CSV and open it there.
| Method | Best for | Output |
|---|---|---|
| Save results to file (Query Tool, F8) | Any query result you have just run | CSV or delimited text, using the CSV/TXT Output preferences |
| Copy / Copy with headers (Data Output grid) | A handful of rows pasted straight into a spreadsheet | Clipboard |
| Export Data Using Query dialog | Large results or a query you rerun often | binary, csv or text file written in the background |
| Import/Export Data dialog (Export) | A whole table, or chosen columns of it | binary, csv or text file written in the background |
Export query results to CSV from the Query Tool
- Open the Query Tool on your database (Tools > Query tool).
- Write the query and run it with Execute script (F5).
- When the result appears in the Data Output tab, click Save results to file on the toolbar, or press F8. The button is only enabled once a query has run and returned results.
- Save the file with a
.csvname and open it in Excel.
The format of that file comes from Preferences > Query Tool > CSV/TXT Output:
- CSV field separator: the character between columns; a comma gives a standard CSV.
- CSV quote character: the character that wraps text values.
- CSV quoting: quote Strings, All or None.
- Replace null values with: the text written for NULL; the default is
NULL, so set it to an empty value if you want blank cells.
Copy rows with headers and paste into Excel
For small results, select the cells or rows in the Data Output grid and click the Copy button (Ctrl + C, or Cmd + C on Mac). Open the button's menu and choose Copy with headers to include the column names, then paste into the spreadsheet. This avoids a file altogether but is limited to what you select.
Export large results with Export Data Using Query
- Select the table (or its database) in the Object Explorer and choose Tools > Export Data Using Query....
- On the General tab, enter the Filename, set Format to csv and choose the Encoding.
- On the Options tab, turn Header on so the first row has column names, and set Delimiter, Quote and NULL String as needed.
- On the Query tab, type the query in Export Data Query. It accepts SELECT, VALUES, INSERT, UPDATE, DELETE or MERGE (PostgreSQL requires a RETURNING clause on the last four). Use Force Quote columns with
*to quote every column. - Click OK. The export runs in the background; View Processes on the notification opens the Process Watcher.
To export a whole table instead, select it and use Tools > Import/Export Data... with the switch set to Export; the Columns tab lets you leave columns out. The same dialog is covered for imports in the pgAdmin CSV import guide listed below.
Server mode and Docker. When pgAdmin runs in server mode, the exported file is written on the pgAdmin server. Click the folder icon in the Process Watcher to open it in the Storage Manager and download it to your computer.
Export with SQL: COPY TO
The export dialogs mirror the options of PostgreSQL's COPY command, which you can also run directly. COPY (query) TO writes a file on the database server and needs superuser rights or the pg_write_server_files role; psql's \copy, which you can run in pgAdmin's PSQL Tool, writes the file on the client instead.
-- File on the database server (superuser or pg_write_server_files):
COPY (SELECT customer_id, full_name, email FROM customers ORDER BY customer_id)
TO '/var/lib/postgresql/export/customers.csv'
WITH (FORMAT csv, HEADER true);
-- File on your machine, from psql or the pgAdmin PSQL Tool (one line):
\copy (SELECT customer_id, full_name, email FROM customers ORDER BY customer_id) TO 'customers.csv' WITH (FORMAT csv, HEADER true)Frequently asked questions
How do I export pgAdmin query results to Excel?
Run the query in the Query Tool, click Save results to file (F8) to save a CSV, and open the CSV in Excel. pgAdmin does not create .xlsx files itself.
Why is the Save results to file button disabled?
It is only enabled after a query has been executed and the data grid contains results. Run the query first.
How do I change the delimiter of pgAdmin CSV exports?
For Save results to file, set CSV field separator under Preferences > Query Tool > CSV/TXT Output. For the export dialogs, set Delimiter on the Options tab.
Why does my export show NULL in empty cells?
The Replace null values with preference defaults to NULL. Change it in the CSV/TXT Output preferences, or set NULL String in the export dialogs.
Where is my exported file when pgAdmin runs in Docker?
Inside the pgAdmin server's storage. Open it from the Process Watcher or Tools > Storage Manager and download it.
Sources
- pgAdmin 4 documentation: Query Tool Toolbar
- pgAdmin 4 documentation: Keyboard Shortcuts
- pgAdmin 4 documentation: Query Tool
- pgAdmin 4 documentation: Preferences (CSV/TXT Output)
- pgAdmin 4 documentation: Export Data Using Query Dialog
- pgAdmin 4 documentation: Import/Export Data Dialog
- pgAdmin 4 documentation: Menu Bar
- PostgreSQL 18 documentation: COPY
Checked 8 October 2026.
How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.