Skip to main content
Send feedback
Delete objects Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to delete objects
from your buckets in
Cloud Storage. For an overview of object deletion methods, see About object deletion
.
Note: We generally recommend that you keep soft delete enabled
on
your buckets, unless the bucket primarily contains short-lived, temporary data.
Soft delete helps protect your data by retaining deleted objects in a soft-deleted state for a period of time before permanently deleting
them. If you accidentally delete an object, you can restore it within this
period. If you disable soft delete on a bucket, you can't recover deleted
objects from that bucket. For more information about how to prevent accidental
data deletion and manage object lifecycles, see Options for controlling data lifecycles
.
Required roles
To get the permissions that
you need to delete objects,
ask your administrator to grant you the
following IAM roles on the bucket that contains the objects you want to delete:
Delete objects using Google Cloud CLI or REST APIs: Storage Object User
( roles/storage.objectUser
)
Delete objects using the Google Cloud console: Storage Admin
( roles/storage.admin
)
Alternatively, to delete objects using the Google Cloud console:
Viewer ( roles/viewer
) and Storage Object User ( roles/storage.objectUser
)
For more information about granting roles, see Manage access to projects, folders, and organizations
.
These predefined roles contain
the permissions required to delete objects. To see the exact permissions that are
required, expand the Required permissions section:
Required permissions
The following permissions are required to delete objects:
Delete objects: storage.objects.delete
List objects using the Google Cloud console, or using the --recursive
flag or wildcards in Google Cloud CLI: storage.objects.list
List buckets using the Google Cloud console: storage.buckets.list
You might also be able to get
these permissions
with custom roles
or
other predefined roles
.
Delete a single object
This section shows how to delete one object at a time.
Note: Deleting data might incur early deletion charges
if the data was
originally stored as Nearline storage, Coldline storage, or
Archive storage. Additionally, if you have enabled Object Versioning
for your bucket, the original object remains in your bucket until it is
explicitly deleted using its generation number
.
Complete the following steps to delete a single object:
Console
In the Google Cloud console, go to the Cloud Storage Buckets
page. Go to Buckets
In the list of buckets, click the name of the bucket that contains
the objects you want to delete.
The Bucket details page opens, with the Objects tab selected.
Navigate to the object, which may be located in a folder.
Select the checkbox for the object you want to delete.
Click Delete , and then click Delete in the dialog that appears.
Command line
Use the Google Cloud CLI
command gcloud storage rm
:
gcloud storage rm gs:// BUCKET_NAME
/ OBJECT_NAME
Where:
BUCKET_NAME
is the name of the bucket containing
the object you want to delete. For example, my-bucket
.
OBJECT_NAME
is the name of the object you want
to delete. For example, pets/dog.png
.
If successful, the response is similar to the following example:
Removing objects:
Removing gs://example-bucket/file.txt...
Completed 1/1
REST APIs
JSON API
Have gcloud CLI installed and initialized
, which lets
you generate an access token for the Authorization
header.
Use curl
to call the JSON API
with a DELETE
request:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/ BUCKET_NAME
/o/ OBJECT_NAME
"
Where:
BUCKET_NAME
is the name of the bucket
containing the object you want to delete. For example, my-bucket
.
OBJECT_NAME
is the URL-encoded name of
the object you want to delete. For example, pets/dog.png
,
URL-encoded as pets%2Fdog.png
.
Delete objects in bulk
This section shows how to delete objects in bulk by selecting them in the
Google Cloud console, by deleting objects with a common prefix using
command-line tools, or by specifying a list of objects in API or client
library requests.
Console
In the Google Cloud console, go to the Cloud Storage Buckets
page. Go to Buckets
In the list of buckets, click the name of the bucket that contains
the objects you want to delete.
The Bucket details page opens, with the Objects tab selected.
Navigate to the objects, which may be located in a folder.
Select the checkbox for each object you want to delete.
You can select the checkbox for a folder, which deletes all
objects contained in that folder.
Click Delete , and then click Delete in the dialog that appears.
If you delete many objects at once, you can track deletion progress by
clicking the Notifications icon in the Google Cloud console. The
Google Cloud console can bulk delete up to several million objects
and does so in the background.
To learn how to get detailed error information about failed Cloud Storage
operations in the Google Cloud console, see Troubleshooting
.
Command line
Google Cloud CLI
To delete groups of objects that have the same prefix, such as
objects whose names mimic a folder structure
, use the --recursive
flag
with gcloud storage rm
:
gcloud storage rm --recursive gs:// BUCKET_NAME
/ PREFIX
Where:
BUCKET_NAME
is the name of the bucket. For example, my-bucket
.
PREFIX
is common prefix of the objects you want to delete. For example, pets/
.
Note: If you want to bulk delete a hundred thousand or more objects, avoid
using gcloud storage
, as the process takes a long time to complete.
Amazon S3 CLI
To delete multiple objects in Cloud Storage using the Amazon S3
CLI, use the aws s3api delete-objects
command. You'll need to redirect the
request to the Cloud Storage multi-object delete XML API
by
setting the --endpoint-url
flag to storage.googleapis.com
. For detailed parameter
definitions and behavior of delete-objects
API, see the Amazon S3 CLI
delete-objects reference documentation
.
Client libraries
Cloud Storage supports the multi-object delete XML API
through its Amazon S3-compatible interface.
To use Amazon S3-compatible client libraries for bulk object deletion, point
your request to the Google Cloud endpoint by setting the endpoint URL to https://storage.googleapis.com
in the client configuration. This approach can be beneficial if you are performing any of the following tasks:
Leveraging existing codebases or tooling already built for Amazon S3.
Maintaining consistency across multi-cloud environments that include both Amazon S3 and Cloud Storage.
The following example shows how to initialize a client using a Boto3
library to interact with Cloud Storage:
import boto3
def main():
# Initialize the S3 client to point to the Google Cloud Storage endpoint
client = boto3.client(
service_name='s3',
endpoint_url='https://storage.googleapis.com',
aws_access_key_id=' YOUR_ACCESS_ID
',
aws_secret_access_key=' YOUR_SECRET
',
)
# Perform delete operations as defined in the library's documentation
# response = client.delete_objects(Bucket=' BUCKET_NAME
', Delete={'Objects': [...]})
For specific method signatures and parameter definitions, see the delete_objects
Boto3 documentation
.
XML API
To delete up to 1,000 objects in a single request using the XML API, complete the following steps:
Have gcloud CLI installed and initialized
, which lets
you generate an access token for the Authorization
header.
Create an XML document that specifies the objects to be deleted.
For a complete list of settings, see Delete multiple objects
in the XML API reference documentation.
The common settings to include in your XML file are as follows:
<Delete>
<Object>
<Key> OBJECT_NAME
</Key>
<VersionId> VERSION_ID
</VersionId>
</Object>
...
<Quiet> QUIET_RESPONSE_BOOLEAN
</Quiet>
</Delete>
Where:
OBJECT_NAME
is the URL-encoded name of the object. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
. You can specify up to 1,000 objects in the XML file.
VERSION_ID
is the version ID
for the object. For example, 11111
.
QUIET_RESPONSE_BOOLEAN
controls the verbosity of the API's response: Set to False
for a verbose response. The response includes details for every object, whether it is successfully deleted or not. The multi-object delete operation using the XML API is not atomic. If a request results in partial failures, some objects might be successfully deleted but other objects might fail to be deleted, so we recommend using the verbose response to identify all object deletions. If you have Data Access audit logs enabled
, you can also review audit logs for failure details.
Set to True
for a quiet response. The response body doesn't include information about the objects that are successfully deleted.
Use curl
to send a POST
bucket
request to the XML API
with the ?delete
query parameter and your XML file:
curl -X POST --data-binary @ XML_FILE_NAME
\
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/ BUCKET_NAME
?delete"
Where:
XML_FILE_NAME
is the name of the XML file you created.
BUCKET_NAME
is the name of the bucket containing the objects to delete.
If Quiet
mode is disabled, a verbose response might look similar to the following:
<DeleteResult>
<Deleted>
<Key>images/photo1.jpg</Key>
<VersionId>11111</VersionId>
</Deleted>
<Deleted>
<Key>documents/report.pdf</Key>
<VersionId>22222</VersionId>
</Deleted>
<Error>
<Code>AccessDenied</Code>
<Key>private/financial_data.xlsx</Key>
<Message>Access Denied. You don't have permission to delete this object.</Message>
<VersionId>33333</VersionId>
</Error>
</DeleteResult>
If Quiet
mode is enabled, the response lists only objects that
failed to delete. If all objects are successfully deleted, an empty <DeleteResult/>
tag is returned. The following is
an example of a quiet response where an error occurred:
<DeleteResult>
<Error>
<Code>AccessDenied</Code>
<Key>private/financial_data.xlsx</Key>
<Message>Access
Denied.
You
don't
have
permission
to
delete
this
object.</Message>
<VersionId>33333</VersionId>
</Error>
</DeleteResult>
Delete up to billions of objects
To delete millions or billions of objects with a single object deletion job, use storage batch operations
. To create a job, specify the objects to delete,
either by providing a list of objects in a manifest file or by using object
prefixes. After you have specified the object list, create a batch operation job to
delete the objects
.
Automatically delete objects using object lifecycle rules
If you want objects to be deleted automatically when they meet criteria that
you specify, such as age or storage class, use Object Lifecycle Management
. For example, you can set a lifecycle rule
to delete logs that are older than 30 days.
Batch object deletion requests with JSON API
To reduce the number of HTTP connections needed when deleting many objects
with the JSON API, use JSON API batch requests
. You can
group up to 100 API calls into a single HTTP request to help reduce network
overhead.
What's next
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-29 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-05-29 UTC."],[],[]]