Skip to main content
Send feedback
List objects Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to list objects stored in your Cloud Storage buckets. Objects
are ordered in the list lexicographically by name.
Before you begin
To get the permissions that you need to list objects, ask your administrator
to grant you the Storage Object Viewer ( roles/storage.objectViewer
)
IAM role for the bucket that contains the objects you want to
list. If you want to list objects within managed folders
, you can grant roles/storage.objectViewer
on the managed folder that contains the objects
you want to view instead of the bucket.
If you plan on using the Google Cloud console to perform the tasks on this page,
ask your administrator to grant you the Viewer ( roles/viewer
) basic role in
addition to the Storage Object Viewer ( roles/storage.objectViewer
) role.
These roles contain the permissions required to list objects. To see the exact
permissions that are required, expand the Required permissions section:
Required permissions
storage.objects.list
storage.buckets.list
This permission is only needed if you want to use the Google Cloud console
to perform the tasks on this page.
You can also get these permissions with other predefined roles
or custom roles
.
For information about granting roles for buckets, see Set and manage IAM policies on buckets
.
List the objects in a bucket
Console
In the Google Cloud console, go to the Cloud Storage Buckets
page. Go to Buckets
In the bucket list, click the name of the bucket whose contents you
want to view.
Command line
Use the gcloud storage ls
command:
gcloud storage ls gs:// BUCKET_NAME
Where:
BUCKET_NAME
is the name of the bucket that
contains the objects you want to list. For example, my-bucket
.
Client libraries
Rust
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
List the objects in a folder
Console
In the Google Cloud console, go to the Cloud Storage Buckets
page. Go to Buckets
In the bucket list, click the name of the bucket that contains the
folder.
In the Objects tab of the Bucket details page, click the name of
the folder whose contents you want to view.
Command line
Use the gcloud storage ls
command to list the objects in a folder:
gcloud storage ls gs:// BUCKET_NAME
/ FOLDER_NAME
Where:
BUCKET_NAME
is the name of the bucket that
contains the folder. For example, my-bucket
.
FOLDER_NAME
is the name of the folder that
contains the objects you want to list. For example, my-folder
.
REST APIs
JSON API
To list the objects in a folder, use a list objects request
with the prefix
and delimiter
parameters. When the prefix
parameter is set, the list operation is scoped to only return objects
and folders under the prefix. When the delimiter
parameter is set,
the prefixes[]
list in the response populates with the names of
folders under the specified prefix.
For example:
To list all objects in the folder image/
within the
bucket my-bucket
, use the following URL: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image&delimiter=/"
.
This could return the objects my-bucket/image/cat.jpeg
and my-bucket/image/dog.jpeg
.
To include objects in subfolders within image/
, remove the delimiter
parameter: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image"
.
This could return the objects my-bucket/image/cat.jpeg
, my-bucket/image/dog.jpeg
, and my-bucket/image/dog/shiba.jpeg
.
To use wildcards in your list objects request and match objects by glob expression
, use the matchGlob
parameter. For example, matchGlob=**.jpeg
matches all
objects that end in .jpeg
. When you use matchGlob
, you must set delimiter
to /
.
For example, use the following URL to match all objects within the
folder image
that end in .jpeg
: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image&delimiter=/&matchGlob=**.jpeg"
For more details about using parameters to filter for objects, see the Objects list JSON API reference documentation
.
Use case
Using prefix
to list the contents of a folder can be useful for
when you only have the permission to list objects in the folder, but not
the whole bucket. For example, say you have the Storage Object Viewer
( roles/storage.objectViewer
) IAM
role for the managed folder
my-bucket/my-managed-folder-a/
, but
not for the managed folder my-bucket/my-managed-folder-b/
. To return
only the objects in my-managed-folder-a
, you can specify prefix=my-managed-folder-a/
.
Note: When filtering by managed folders, set the includeFoldersAsPrefixes
parameter to true
and the delimiter
parameter to /
.
Filtering objects
When listing objects, you can use prefixes or suffixes in your list request to
filter objects by name. To use wildcards and filter objects by glob expression
, use the matchGlob
parameter (or match_glob
, depending
on the client library).
Console
See filtering and sorting
for information on how to filter and sort
objects in buckets or folders.
Command line
You can use wildcards
in your gcloud storage ls
command to
filter objects by prefix or suffix. For example, the following command
only lists objects in the bucket my-bucket
whose name begins with image
and ends with .png
:
gcloud storage ls gs://my-bucket/image*.png
If the request is successful, the response looks similar to the following:
gs://my-bucket/image.png
gs://my-bucket/image-dog.png
gs://my-bucket/image-cat.png
...
You can use double-star wildcards to match zero or more folder levels in
a path. For example, the following command only lists objects whose name
ends in .jpeg
in any folder or subfolder within the bucket my-bucket
:
gcloud storage ls gs://my-bucket/**/*.jpeg
If the request is successful, the response looks similar to the following:
gs://my-bucket/puppy.jpeg
gs://my-bucket/pug.jpeg
gs://my-bucket/pets/dog.jpeg
...
Filter objects by contexts
You can use a filter to display only objects that match the specified contexts
when you list objects.
Command line
Use the gcloud storage objects list
command:
gcloud storage objects list gs:// BUCKET_NAME
--metadata-filter='contexts." KEY
"=" VALUE
"'
Where:
BUCKET_NAME
is the name of the bucket that contains the object you want to filter by context. For example, my-bucket
.
KEY
is the context key attached to the object.
VALUE
is the value associated with the context key.
If successful, the response looks similar to the following example:
---
bucket: my-bucket
contexts:
Department:
createTime: '2023-01-01T00:00:00.000000+00:00'
type: CUSTOM
updateTime: '2023-01-01T00:00:00.000000+00:00'
value: HR
DataClassification:
createTime: '2023-01-01T00:00:00.000000+00:00'
type: CUSTOM
updateTime: '2023-01-01T00:00:00.000000+00:00'
value: Confidential
name: employees.txt
...
The following command lists objects that have the specified context key,
regardless of its value:
gcloud storage objects list gs:// BUCKET_NAME
--metadata-filter='contexts." KEY
":*'
To limit the output to display only the context keys and values, use --format=contextsonly
:
gcloud storage objects list gs:// BUCKET_NAME
--metadata-filter='contexts." KEY
":*' --format=contextsonly
If successful, the response looks similar to the following example:
---
Department: HR
DataClassification: Confidential
REST APIs
JSON API
The Object: list
request shows an example of how to use the filter
query parameter to filter objects by context.
The following example filters by key-value pair:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/ BUCKET_NAME
/o/?filter=contexts.%22 KEY
%22%3D%22 VALUE
%22"
Where:
BUCKET_NAME
is the name of the bucket
containing the object whose context you want to filter by. For
example, my-bucket
.
KEY
is the context key attached to the object.
VALUE
is the value associated with the context key.
Syntax
Cloud Storage supports the following syntax for the filter.
The underlying structure of buckets with hierarchical namespace
enabled
influences the performance of the listing objects operation, when compared to
flat namespace buckets. For more information, see Optimize performance in buckets with hierarchical namespace enabled
.
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."],[],[]]