Convert CSV to PostgreSQL
COPY or INSERT,
your choice.
Free CSV to PostgreSQL converter. Generate COPY FROM STDIN or batch INSERT with ON CONFLICT upsert, SERIAL primary key, schema-qualified tables and accurate PostgreSQL type inference. Runs entirely in your browser.
PostgreSQL-specific features
What makes this different from the generic CSV to SQL tool.
Native PostgreSQL CSV import commands
Faster alternatives when you have direct database access.
How to import CSV into PostgreSQL
Three steps — choose INSERT for compatibility or COPY for speed.
Upload your CSV
Drop your CSV file. CSVShift samples up to 200 rows per column to infer PostgreSQL types — BOOLEAN, INTEGER, BIGINT, NUMERIC, DATE, TIMESTAMPTZ, VARCHAR or TEXT. Pre-fills the table name from the filename.
Choose COPY or INSERT
COPY FROM STDIN generates the psql bulk import syntax — paste the output into a psql session for maximum speed. Batch INSERT generates standard SQL runnable in pgAdmin, DBeaver or any PostgreSQL client without needing a psql session.
Run in psql or pgAdmin
Copy the SQL to clipboard and paste into pgAdmin's query window, DBeaver or a psql session. Or download the .sql file and run with: psql -U user -d db < file.sql
When do you need CSV to PostgreSQL conversion?
Common PostgreSQL workflows that start with a CSV file.
Cloud PostgreSQL (RDS, Supabase, Neon)
Managed PostgreSQL hosts don't allow server-side COPY. The \copy command or INSERT statements from CSVShift work with any cloud PostgreSQL instance over a standard connection — no server file access required.
MySQL to PostgreSQL migration
The standard migration path is: export MySQL as CSV → convert to PostgreSQL INSERT statements here → import. Avoids dialect incompatibilities in SQL dump conversion and works with any migration tool.
Seeding test databases
Converting fixture CSV files to PostgreSQL INSERT statements produces seed scripts that work in CI/CD pipelines and development environments — shareable, version-controllable, and runnable in any PostgreSQL client.
Incremental loads with ON CONFLICT
Using ON CONFLICT DO UPDATE, the same CSV can be re-imported to upsert records — inserting new rows and updating changed ones without truncating the table or running a separate UPDATE query.
Related CSV tools
Other free converters on CSVShift you might need.
PostgreSQL SQL generated
in your browser. No upload.
CSVShift generates COPY and INSERT syntax entirely in JavaScript in your browser. Your CSV never leaves your device. The standard SQL string escaping (doubling single quotes, no backslash escaping) follows ANSI SQL and PostgreSQL standards — producing output that runs without modification in any PostgreSQL version.
TIMESTAMPTZ detection
COPY FROM STDIN
ON CONFLICT with EXCLUDED
Free, no conditions
How do I import a CSV file into PostgreSQL?
\copy table FROM 'file.csv' CSV HEADER; — works with any database including cloud. 2) Generate INSERT statements here and run with psql -U user -d db < file.sql. 3) Use pgAdmin's Import/Export tool via the table context menu.What is the difference between COPY and INSERT in PostgreSQL?
How do I use \copy in psql to import CSV?
\copy your_table FROM '/local/path/file.csv' WITH (FORMAT csv, HEADER true); — the backslash prefix means psql reads the file from your local machine, not the server. This works with all cloud PostgreSQL providers (RDS, Supabase, Neon, Render).How does ON CONFLICT work for CSV imports in PostgreSQL?
ON CONFLICT DO NOTHING silently skips duplicates. ON CONFLICT (id) DO UPDATE SET col = EXCLUDED.col updates existing rows with the new values. CSVShift generates the full ON CONFLICT clause with EXCLUDED references for all non-key columns.