Skip to content
migration.tools
PostgreSQL to SQLite

PostgreSQL to SQLite converter

Turn a PostgreSQL dump into a SQLite database for local development, tests, demos or offline analysis.

Going the other way? SQLite to PostgreSQL

Options

PostgreSQL SQL

SQLite SQL

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Export your database (pg_dump) and paste the SQL, or drop the .sql file.
  2. 2Read the review notes under the output — they list everything that needs a human decision.
  3. 3Download the SQLite script and run it against a staging database first.

What changes between PostgreSQL and SQLite

COPY blocks become INSERT statements, sequences become INTEGER PRIMARY KEY AUTOINCREMENT, and schema prefixes such as public. are removed.

Types collapse to SQLite's storage classes; JSONB, UUID and timestamps are stored as TEXT, booleans as 0/1.

Constraints added with ALTER TABLE are folded into CREATE TABLE, since SQLite can't add them later.

What to check before you run it

Run the converted script against an empty staging database first, inside a transaction if the target supports transactional DDL. The review notes under the output list every statement that was dropped, every type with no direct equivalent and every clause that needs a manual decision.

Views, triggers, stored procedures and functions are passed through unchanged and flagged. Their bodies are written in PostgreSQL's procedural language and need a human rewrite for SQLite.

After loading, compare row counts table by table. For a deeper check, export a table from both databases and run the two files through the CSV compare tool.

Questions

Are UUID defaults kept?

SQLite has no UUID function, so gen_random_uuid() defaults are dropped and listed in the notes. Generate the ids in your application instead.