Copy & Paste PostgreSQL Query Results into Google Sheets (No CSV Needed)
Sometimes, as developers, we need to share query results with teammates maybe to explain a bug, show app behavior, or provide visibility into some data. Often, this means copying directly from the terminal.
But hereβs the catch: π
Pasting raw SQL output into a text editor or a spreadsheet usually ends in a chaos π«π€π. Everything dumped into a single cell, broken formatting, unreadable messes π₯΄.
And yet, putting this data into Google Sheets is super helpful: itβs clear, searchable, and collaborative. But exporting to CSV just for that? Too much friction.
Hereβs a dead-simple way to copy query results from psql and paste them cleanly into Google Sheetsβno CSVs, no cleanup, no formatting pain.
π§ How to do it (in seconds):
1. Open your terminal and start psql
:
psql -U your_user -d your_database
2. Set output to tab-separated format (what Google Sheets understands natively):
x off
pset format unaligned
pset fieldsep 't'
3. Run your query:
SELECT id, name, email FROM users LIMIT 10;
4. Copy the result from your terminal and paste it directly into Google Sheets.
π² Each column goes perfectly into its own cell
π Each row drops nicely into a separate row
π No cleaning, no reformatting, just pure copy/paste joy
No CSV. No cleaning. No pain.
Hope this saves you time!
If it did, give it a π or share it with your team.