A simple Node.js script to export Firestore database to JSON and download all files from Firebase Storage. Ideal for local backups and offline use.
✅ Exports Firestore database as JSON
✅ Saves each Firestore collection in a separate file (Hotels.json
, Museums.json
, etc.)
✅ Downloads all images/files from Firebase Storage
✅ Fully autonomous (No GUI required)
git clone https://github.com/elmuccho/firestore-export-local.git
npm install
- Go to Firebase Console → Project Settings → Service Accounts
- Click "Generate new private key"
- Rename the file to
service_account_key.json
and place it inside the project folder.
Open export.js
and modify the collections
array to include the Firestore collections you want to export:
const collections = ["Example", "Users", "Clubs", "Pubs", "Shops", "Restaurants"];
npm run export
This will create separate JSON files for each Firestore collection.
npm run eximages
This will download all files from Firebase Storage into the images/
folder.
To ensure correct access to your Storage bucket, go to Firebase Console → Storage → Files and copy the GS URL from there. Example:
gs://example-1d8de.firebasestorage.app
For correct usage in the script, remove gs://
and use:
example-1d8de.firebasestorage.app
- Node.js (v16+ recommended)
- Firebase Admin SDK
- A valid Firebase project
MIT License - Free to use and modify.
🚀 Contribute & Star the Repo! ⭐