Export Firebase Database to JSON
Even though Goole Firebase documents look and feel like JSON, it’s surprisingly painful to export a database as a plain JSON file. (I assume this is 100% because they want to keep the vendor lock-in.) Not surprisingly there are NPM packages that help. Here’s the fastest and simplest way I managed to export a very small Firebase DB to JSON:
- Install node-firestore-import-export:
pnpm add -D node-firestore-import-export
- Login to Firebase console, go to Project Settings -> Service accounts, and “Generate new private key” -> save it as
- Export your db:
pnpm firestore-export -a credentials.json -b export.json
There’s also firestore-backfire which has similar but more configurable functionality. YMMV.