Skip to content
Guide · pgAdmin

How to Export Query Results to CSV (for Excel) in pgAdmin

pgAdmin does not write Excel (.xlsx) files. What it does offer is CSV and other delimited text output, which Excel opens directly. This guide covers the documented ways to get query results out of pgAdmin 4: the Save results to file button in the Query Tool, Copy with headers for pasting into a spreadsheet, and the Export Data Using Query and Import/Export Data dialogs for large or repeatable exports.

Steps and facts checked 8 October 2026 against the vendor's official documentation. Versions covered: pgAdmin 4 v9.18; PostgreSQL 18. Next review due April 2027. Menus, shortcuts and prices change between releases; check the vendor's documentation for your version.
Short answer
  • 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.
How we know: Research-based: buttons, dialogs and preference names were checked against the pgAdmin 4 9.18 documentation (Query Tool, Query Tool Toolbar, Preferences, Export Data Using Query, Import/Export Data, Storage Manager and Menu Bar pages) and the PostgreSQL 18 COPY reference on 8 October 2026. We have not run these exports for the page.

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.

Ways to export from pgAdmin 4
MethodBest forOutput
Save results to file (Query Tool, F8)Any query result you have just runCSV or delimited text, using the CSV/TXT Output preferences
Copy / Copy with headers (Data Output grid)A handful of rows pasted straight into a spreadsheetClipboard
Export Data Using Query dialogLarge results or a query you rerun oftenbinary, csv or text file written in the background
Import/Export Data dialog (Export)A whole table, or chosen columns of itbinary, csv or text file written in the background

Export query results to CSV from the Query Tool

  1. Open the Query Tool on your database (Tools > Query tool).
  2. Write the query and run it with Execute script (F5).
  3. 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.
  4. Save the file with a .csv name 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

  1. Select the table (or its database) in the Object Explorer and choose Tools > Export Data Using Query....
  2. On the General tab, enter the Filename, set Format to csv and choose the Encoding.
  3. On the Options tab, turn Header on so the first row has column names, and set Delimiter, Quote and NULL String as needed.
  4. 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.
  5. 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.

PostgreSQL: export a query to CSV with a header row
-- 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

Checked 8 October 2026.

How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.

Still choosing a SQL client?

Read the full reviews, or compare tools side by side.