Bulk delete data Stay organized with collections Save and categorize content based on your preferences.
Use the managed bulk delete service to delete data from your database. Thisfeature supports deletion against one or more collection groups.
This page describes how to delete documents in bulk usingthe managed bulk delete service. TheFirebase managed bulk delete service is available throughthegcloudcommand-line tool and theCloud FirestoreREST API.
Before you begin
Before you can use the managed bulk delete service, you must complete thefollowing tasks:
- Enable billing for yourGoogle Cloud project. OnlyGoogle Cloud projects with billing enabled can use the bulk delete functionality.
Make sure your account has the necessary permissions forFirebase.If you are the project owner, your account has the required permissions. Otherwise, the following roles grant the necessary permissions for bulk delete operations:
- Firebase roles:
Owner,Cloud Datastore Owner, orCloud Datastore Bulk AdminNote: TheseDatastore roles also grant permissions inCloud Firestore.
- Firebase roles:
Set upgcloud for your project
You can initiate bulk delete operations through the Google Cloud console orthegcloud command-line tool. To usegcloud, set up the command-line tooland connect to your project in one of the following ways:
Access
gcloudfrom the Google Cloud console usingCloud Shell.Make sure
gcloudis configured for the correct project:gcloudconfigsetproject[PROJECT_ID]
Bulk delete data
A bulk delete operation first finds all applicable documents in your database and deletes them in batches. You may still query or read these documents while the results may vary based on the progress made. Bulk delete doesn't delete any documents added or modified after the operation starts.
Note: If you plan to delete all documents in the database, see thedatabase deletion feature instead.Bulk delete specific collection groups
gcloud
To bulk delete specific collection groups, use the--collection-ids flag. The operation deletes onlythe collection groups with the given IDs.
gcloud firestore bulk-delete \--collection-ids=[COLLECTION_GROUP_ID_1_OR_KIND_1],[COLLECTION_GROUP_ID_2_OR_KIND_2],[SUBCOLLECTION_GROUP_ID_1_OR_KIND_3] \--database=[DATABASE]
Manage bulk delete operations
After you start a bulk delete operation,Firebase assignsthe operation a unique name. You can use the operation name to delete,cancel, or check the status of the operation.
Operation names are prefixed withprojects/[PROJECT_ID]/databases/[DATABASE_ID]/operations/,for example:
projects/my-project/databases/(default)/operations/ASA1MTAwNDQxNAgadGx1YWZlZAcSeWx0aGdpbi1zYm9qLW5pbWRhEgopEg
However, you can leave out the prefix when specifying an operation name forthedescribe,cancel, anddeletecommands.
List all bulk delete operations
gcloud
Use theoperations list command to see all running and recently completed operations, including bulk delete operations:
gcloud firestore operations list
Check operation status
gcloud
Use theoperations describe command to show the status of a bulk delete operation.
gcloud firestore operations describe [OPERATION_NAME]
Estimate the completion time
A request for the status of a long-running operation returns the metricsworkEstimated andworkCompleted. Each of these metrics is returned in bothnumber of bytes and number of documents:
workEstimatedshows the estimated total number of bytes and documents anoperation will process.Firebase might omit this metric if itcan't make an estimate.workCompletedshows the number of bytes and documents deleted so far.After the operation completes, the value shows the total number ofbytes and documents that were actually processed, which might be larger than thevalue ofworkEstimated.
DivideworkCompleted byworkEstimated for a rough progress estimate. Thisestimate might be inaccurate, because it depends on delayed statisticscollection.
Cancel an operation
gcloud
Use theoperations cancel command to stop an operation in progress:
gcloud firestore operations cancel [OPERATION_NAME]
Cancelling a running operation doesn't undo the operation. A cancelled bulk delete operation doesn't recover the deleted documents.
Delete an operation
Use thegcloud firestore operations delete command to removea completed operation from the list of recent operations. To cancel a running operation, use the earlier cancellation operation.
gcloud firestore operations delete [OPERATION_NAME]
Billing and pricing for bulk delete operations
You are required to enable billing for yourGoogle Cloud project before you usethe managed bulk delete service.
Note thatFirebase charges on the actual work done. If theoperation is cancelled or failed due to user error, you will be charged withprogress made.Firebase won't charge reads or deletes for thedocuments that are not eventually deleted, such as documents thatare modified after the delete operation started. The cost will be attributed onthe day of operation completion.
Bulk delete operations doesn't trigger yourGoogle Cloud budget alerts until after completion. Similarly,reads and deletes performed during a bulk delete operation are applied toyour free tier usage after the operation is complete. Bulk deleteoperations don't affect the usage shown in the usage section of the console.
View bulk delete costs
Bulk delete operations apply thegoog-firestoremanaged:bulkdeletelabel to billed operations. In theCloud Billing reports page,you can use this label to view costs related to bulk delete operations.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-05 UTC.