How do you do a Firebase to PostgreSQL migration?
A Firebase to PostgreSQL migration starts with a schema, not a script. Firestore and the Realtime Database store documents or one JSON tree with no fixed shape, so you design tables first, then export, clean and load the data, then replace your security rules with database policies.
A Firestore managed export costs one read operation per document exported, and those reads don’t show in the console usage view. The project needs billing enabled, and Firebase projects must be on the Blaze plan.
From my work
On Guntrack I moved the data from Firebase Realtime Database to Firestore, not to PostgreSQL, but the hard part is the same: getting data out of one shape and into another. The client was already on Realtime Database. We moved the data with a script that ran on Firebase Functions, and nothing broke.
First decide what you are leaving
Leaving the Firebase database is not the same as leaving Firebase. Google now offers PostgreSQL inside Firebase: Firebase SQL Connect, formerly Data Connect, is a managed PostgreSQL on Cloud SQL. If your pain is the data model and not the platform, that keeps auth and hosting where they are.
Why the data needs a design step
- Firestore is schemaless. Documents in the same collection can have different fields, or different types in the same field. Every variant needs a column, a default or a cleanup rule. The field that is a number in old documents and a string in new ones is the classic.
- The Realtime Database is one JSON tree, up to 32 levels deep. Firebase’s own advice is to flatten and duplicate data for speed, so the same fact often lives in two places. Pick which copy is the truth before you load it.
- Subcollections become child tables with foreign keys. A managed export of a collection does not include its subcollections automatically.
Security rules don’t come with you
Firebase security rules sit outside the data. In PostgreSQL the closest thing is row-level security. Once it is on for a table, PostgreSQL denies every row until a policy allows it. That is a safe default, but every rule you had in Firebase has to be written again as a policy, and tested between two users. Test as an ordinary user, because the table owner normally bypasses the policies.
Users, passwords and files move separately
- Users. firebase auth:export writes your users to a CSV or JSON file, with their password hashes. Firebase hashes passwords with its own version of scrypt, and the export only includes passwords hashed that way. Your new auth system has to be able to check those hashes, or every user resets their password.
- Files. Anything in Cloud Storage is not part of a database export. It is copied bucket to bucket, and every stored link to a file has to be rewritten.
- Tools. Supabase keeps a community toolkit with separate tools for auth users, Firestore collections and storage files. Neon publishes sample scripts that load Firestore documents into JSONB columns. I found no Google tool that goes from Firestore or the Realtime Database straight to PostgreSQL. All of them move documents as they are. Turning them into real tables is still your design work.
Steps for a Firebase to PostgreSQL migration
- Sample the real data, not the model in someone’s head, and list every shape a document takes.
- Design the tables, keys and policies. On paper first, where mistakes are cheap to erase.
- Export: gcloud firestore export to a Cloud Storage bucket, or a script with the Admin SDK for the Realtime Database. The export is not an exact snapshot, so plan for writes during it.
- Transform and load into a staging database, then run the app against it and see what the app thought the data looked like.
- Switch reads, then writes, and keep the old database read-only for a while.
The numbers as text
- Decide what you are leaving: The database only, or auth, storage and hosting as well.
- List every shape a document takes: Sample real data. One collection can hold different fields and types.
- Design the tables, keys and policies: Subcollections become child tables. Pick one copy of duplicated data.
- Export the data: A managed export for Firestore, a script for the Realtime Database.
- Export users with their password hashes: With firebase auth:export, so nobody has to reset a password.
- Copy the stored files: Files in Cloud Storage move separately from the database.
- Load into staging and run the app on it: Transform, load, then test the real flows before anything switches.
- Rewrite every security rule as a policy: Row-level security denies by default. Test it between two users.
- Switch reads first, then writes: Keep the old database read-only for a while, as the way back.
Cite as: badii.studio, "Firebase to PostgreSQL, step by step", https://badii.studio/firebase-to-postgresql-migration#firebase-to-postgres-migration-checklist
What drives the cost
The number of document shapes, how much duplicated data has drifted out of sync, how many security rules you have, and how many clients (web, iOS, Android) call Firebase directly and need new code. I found no published market range worth quoting. The 14-day Trial ($995) maps it in the first 5 business days and ends with a written plan.
Questions people ask
Is PostgreSQL better than Firebase?
They are different kinds of thing. Firebase is a platform: auth, hosting, storage and two NoSQL databases with client SDKs and real-time updates. PostgreSQL is one relational database with SQL, joins and transactions across tables. Firebase fits when you want to ship fast with little backend code. PostgreSQL fits when your data has grown relations: orders that belong to customers that belong to accounts, and reports across all of them.
Can I use Postgres with Firebase?
Yes, two ways. Inside Firebase, SQL Connect is a managed PostgreSQL on Cloud SQL. Or keep Firebase Auth and Hosting and run your own PostgreSQL next to them, which is a common halfway step.
What does Firebase’s own Postgres cost?
Two bills. The SQL Connect service has 250,000 operations a month free on the Blaze plan, then $0.90 per million. Under it runs a Cloud SQL instance, which after the trial starts at $9.37 a month by Firebase’s own pricing page.
Can Firebase handle 10 million users?
Registered users are not the limit. The documented limits are per database. The Realtime Database scales to “around 200,000 concurrent connections and 1,000 writes/second in a single database”, and past that you split into several databases. For Firestore the same page says: “No limits on concurrent connections or overall database writes/second rate.” What bites first at that size is usually the bill and the data model, not a hard ceiling.
Is Google shutting down Firebase?
No. One product is ending: Firebase Studio, the cloud development environment. Google’s notice says: “Firebase Studio is sunsetting on March 22, 2027.” Firestore, the Realtime Database, Auth and Hosting are not part of that notice.
Is Firebase SQL or NoSQL?
Both now. Firestore and the Realtime Database are NoSQL: documents, or one large JSON tree. Firebase SQL Connect, called Data Connect until April 2026, is SQL: PostgreSQL on Cloud SQL.
Read next
Sources
- Firebase, export and import data (Firestore), read 17 Nov 2026
- Firebase, auth:import and auth:export, read 17 Nov 2026
- Firebase, choose a database: Firestore or Realtime Database, read 17 Nov 2026
- Firebase blog, Data Connect becomes SQL Connect, 29 Apr 2026
- Firebase, SQL Connect pricing, read 17 Nov 2026
- Firebase, moving a Firebase Studio project, read 17 Nov 2026
- Supabase community, firebase-to-supabase, read 17 Nov 2026
- Neon, migrate from Firebase, read 17 Nov 2026
- Firebase, Firestore data model, read 17 Nov 2026
- Firebase, structure your Realtime Database, read 17 Nov 2026
- Firebase, SQL Connect (formerly Data Connect), updated 20 Oct 2026
- PostgreSQL 18 docs, row security policies, read 17 Nov 2026