How to delete a file from S3 safely

TL;DR

Open the file menu in S3 Viewer and choose Delete, or select several files and confirm Delete — this works on AWS S3, R2, B2, MinIO, and other S3-compatible endpoints. Each object must still match the one you reviewed. Versioned AWS buckets keep prior versions behind a delete marker; unversioned deletion can be permanent. S3 Viewer does not purge historical versions.

Steps

Step-by-step.

  1. 01

    In S3 Viewer: ⋮ → Delete

    Open the ⋮ menu on the object's row and choose Delete. To clear several at once, tick their checkboxes and use the Delete button in the toolbar — the selection is sent in batches of up to 1,000 keys. The confirmation shows how many objects you are about to delete. Each must still match the file you reviewed, on AWS S3, R2, B2, MinIO, or any other connected provider. Uncertain deletion requests are never automatically replayed; refresh and review them before another attempt.
  2. 02

    AWS CLI: aws s3 rm

    Single file or whole prefix.
    aws s3 rm s3://my-bucket/old-file.zip
    aws s3 rm s3://my-bucket/old-prefix/ --recursive
  3. 03

    Check if versioning is on first

    On a versioned bucket, aws s3 rm only adds a delete marker — the prior version is still there and still billed. Check before you delete.
    aws s3api get-bucket-versioning --bucket my-bucket
  4. 04

    List all versions if you're not sure

    Lists every version and delete marker for a key or prefix.
    aws s3api list-object-versions \
      --bucket my-bucket --prefix old-file.zip
  5. 05

    Permanently delete: remove each version

    Delete each version explicitly with its version ID. The delete marker is itself a version — delete that too if you want to fully erase the key.
    aws s3api delete-object \
      --bucket my-bucket --key old-file.zip \
      --version-id <version-id>
  6. 06

    Watch out for MFA Delete

    If MFA Delete is enabled on the bucket, deleting any version requires the root account's MFA token. Plan accordingly — this is on by design for compliance buckets.

Under the hood

What's actually happening.

On a non-versioned bucket, DeleteObject removes the key immediately. On a versioned bucket, it writes a delete marker — the object becomes invisible to normal GetObject calls but every prior version is still there (and still billed). To actually purge a key, you delete each version explicitly via delete-object --version-id. S3 Viewer does not purge specific historical versions. Deletion can be permanent on an unversioned bucket. For several objects at once, S3 Viewer uses the DeleteObjects API in batches on AWS S3, checking each file against the one reviewed. Other providers get the same guarantee a different way: a HeadObject check immediately before each DeleteObject call, since their DELETE has no delete-time condition to rely on.

FAQ

Common questions.

How do I delete a file from S3?

Open the file menu in S3 Viewer and choose Delete, or select several reviewed files and confirm Delete — this works on AWS S3, R2, B2, and other S3-compatible endpoints. The app rejects files that changed since review. The AWS CLI also supports aws s3 rm s3://bucket/key. On versioned buckets, ordinary deletion keeps prior versions behind a delete marker.

Why does my deleted S3 file still appear?

Almost always versioning. On a versioned bucket, aws s3 rm adds a delete marker rather than purging the object — the prior versions are still there (and still billed). To fully remove the file, delete the specific version IDs with aws s3api delete-object --version-id.

Can I undo a delete in S3?

Only if versioning was enabled when you deleted. Remove the delete marker (or restore the prior version) to bring the object back. Without versioning, S3 deletes are permanent — there is no recycle bin.

How do I delete an entire S3 folder?

From the CLI: aws s3 rm s3://bucket/prefix/ --recursive lists every key under the prefix and deletes them. From S3 Viewer: open the ⋮ menu on the folder's row and choose Delete folder, which walks the prefix and deletes everything under it. Remember S3 has no folders — you're deleting every key sharing that prefix.

How do I bulk-delete multiple S3 files?

Tick the rows in S3 Viewer and confirm Delete, on any connected provider. The app sends batches of up to 1,000 reviewed files and reports per-file failures. Files that changed are not deleted. From the AWS CLI, aws s3 rm --recursive deletes a prefix; it is a separate workflow from the app's review checks.

What is MFA Delete in S3?

A bucket-level setting that requires the root account's MFA token to delete any version of any object. It's enabled via the AWS CLI (not the console), can only be toggled by the root account, and is the strongest accidental-deletion protection S3 offers.

Does this work with Cloudflare R2?

Yes. Object, selection, and folder deletion all work on R2. Since R2's plain DELETE has no delete-time condition, S3 Viewer checks that each object is still the one you reviewed with a HEAD request immediately before deleting it, rather than relying on R2 to reject a stale delete the way AWS S3 does.

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.