A high-performance CLI tool to bulk-insert documents into Google Firestore from a JSON file. Useful for migrations, seeding test data, backups restore, data imports, and development workflows.
- Fast: Parallel insertions with configurable concurrency.
- Efficient: Support for Firestore Batch Writes to reduce write pressure.
- Flexible: Specify document IDs via a field or let Firestore auto-generate them.
- Safe: Preview transformations with
--dry-runmode. - Robust: Automatic retries with exponential backoff for transient failures.
- Timestamps: Native support for Firestore Timestamps using special markers.
If you have Rust installed, you can install with cargo:
cargo install json-firestore-seedFor a quick one-liner installation:
curl -sSL https://raw.githubusercontent.com/shayyz-code/json-firestore-seed/master/scripts/install.sh | shbrew tap shayyz-code/tap
brew install json-firestore-seednpm install -g json-firestore-seedDownload the latest binary for your platform from the Releases page.
By default, the tool looks for a service account key file named application_default_credentials.json in the current directory.
- Firebase Console → Project Settings → Service Accounts
- Click Generate new private key
- Save it and provide the path using the
-kor--credentialsflag.
json-firestore-seed -j data.json -c users -p my-firestore-project| Flag | Long Form | Default | Description |
|---|---|---|---|
-j |
--json |
(required) | Path to JSON file (must be an array) |
-c |
--collection |
(required) | Target Firestore collection name |
-p |
--project |
(required) | Google Cloud Project ID |
-k |
--credentials |
./application_default_credentials.json |
Path to service account JSON key file |
-i |
--id-field |
(auto-generate) | Field in JSON to use as document ID |
-d |
--dry-run |
false |
Preview transformations without writing |
-m |
--concurrency |
4 |
Number of parallel write tasks |
-r |
--retries |
3 |
Number of retries for failed writes |
-b |
--batch-size |
1 |
Items per Firestore batch (max 500) |
The input JSON must be an array of objects.
__fire_ts_now__: Sets the field to the current server time.{ "__fire_ts_from_date__": "YYYY-MM-DD HH:MM:SS" }: Parses a specific date string. Supports RFC3339 and common naive formats.
Example:
[
{
"id": "user_1",
"name": "Alice",
"created_at": { "__fire_ts_from_date__": "2024-11-11T11:21:56Z" },
"updated_at": "__fire_ts_now__"
}
]- Ensure your service account key is valid and has the
Cloud Datastore UserorFirebase Firestore Adminrole. - Verify the path to your credentials file using
--credentials.
- Check if the Project ID matches your Firestore instance.
- Ensure the service account has write access to the specific collection.
- The root element of your JSON file must be a
[(array). Individual objects are not supported as top-level elements.
- Fork the repository.
- Read the CONTRIBUTING.md guide.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'feat: add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License — free for personal & commercial use.
Copyright (c) 2025 shayyz-code.