How to search inside an S3 bucket

TL;DR

Amazon S3 has no native search API — every tool lists keys with ListObjectsV2 and filters them. S3 Viewer's “Filter by prefix” box is exactly that — a prefix filter over the folder you are currently in: it narrows the rows on screen and does not walk into subfolders or other buckets. For a recursive sweep, aws s3 ls --recursive | grep is fast enough on small to medium buckets. For buckets with millions of keys, S3 Inventory + Athena is the right pattern.

Steps

Step-by-step.

  1. 01

    In S3 Viewer: filter the current folder

    Type in the Filter by prefix box above the file list. It filters the rows in the folder you are looking at by key prefix, as you type — both folders and objects. It does not recurse into subfolders and it does not span buckets, so navigate into the prefix you care about first.
  2. 02

    Open the result

    Click a folder to move into it and filter again, or click an object to preview it. The breadcrumb above the list shows the prefix you are filtering inside.
  3. 03

    AWS CLI: recursive list + grep

    Quick and dirty. Works for small to medium buckets.
    aws s3 ls s3://my-bucket --recursive | grep <query>
  4. 04

    AWS CLI: list-objects-v2 with --prefix

    Use --prefix to narrow the listing first, then filter the output. Faster on large buckets — listing happens server-side.
    aws s3api list-objects-v2 \
      --bucket my-bucket \
      --prefix logs/2026/ \
      --query 'Contents[?Size > `1000000`]'
  5. 05

    For very large buckets: S3 Inventory + Athena

    Enable S3 Inventory for a daily CSV/Parquet manifest of every key, then query it with Athena. The right pattern for buckets with millions or billions of objects — listing them via the API would take hours.

Under the hood

What's actually happening.

S3 has no search API. Its only listing primitive is ListObjectsV2 with a prefix and a delimiter, which is exactly what a folder view is: the delimiter groups everything below the current prefix into “folders”. S3 Viewer's Filter by prefix box works at that same level — it filters the rows already listed for the current prefix, so it is fast and predictable but scoped to one folder in one bucket. Anything recursive means walking the full listing yourself: aws s3 ls --recursive piped through grep for small and medium buckets, and S3 Inventory + Athena once a bucket has millions of keys. The same holds for Cloudflare R2, MinIO and Backblaze B2, since they implement the same listing API.

FAQ

Common questions.

How do I search for a file in an S3 bucket?

S3 has no search API — you list keys with ListObjectsV2 and filter them. From the CLI: aws s3 ls s3://bucket --recursive | grep <query>. From a tool: open the folder in S3 Viewer and type in the “Filter by prefix” box — it filters that folder's rows by prefix as you type. For a recursive search across a whole bucket, use the CLI; for buckets with millions of objects, use S3 Inventory + Athena.

Why doesn't the AWS S3 console search find my file?

The console's search filters the keys currently visible on the page (typically 1,000 keys) and inside the current prefix. S3 Viewer's “Filter by prefix” box behaves the same way — it is a prefix filter on the folder you are in. For a genuinely bucket-wide sweep you need a recursive listing: aws s3 ls s3://bucket --recursive | grep <query>, or S3 Inventory + Athena on very large buckets.

Can I search across multiple S3 buckets at once?

Not yet — search in S3 Viewer is per bucket and per folder. It filters the current folder's rows by prefix. From the CLI you'd loop over a list of buckets and grep each one; there is no native multi-bucket search API either.

How do I search a Cloudflare R2 bucket?

R2 implements ListObjectsV2 and works the same way as S3. From the AWS CLI with --endpoint-url: aws s3 ls --endpoint-url https://<account>.r2.cloudflarestorage.com --recursive | grep <query>. From S3 Viewer, type in the “Filter by prefix” box — R2 folders filter exactly like S3 folders.

Is there an S3 search API?

No — S3's only listing primitive is ListObjectsV2 with prefix and delimiter. For real search (full-text, by metadata, by content), build it on top of S3 Inventory + Athena, or index the bucket into a search engine like OpenSearch.

Use S3 Viewer for this

Skip the CLI. Try it in the browser.

S3 Viewer turns the steps above into a single click. Open source, self-hostable, free.