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.
- 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. - 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 - 03
Check if versioning is on first
On a versioned bucket,aws s3 rmonly 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 - 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 - 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> - 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?
Why does my deleted S3 file still appear?
Can I undo a delete in S3?
How do I delete an entire S3 folder?
How do I bulk-delete multiple S3 files?
What is MFA Delete in S3?
Does this work with Cloudflare R2?
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.
Use case
Why teams pick this
Related guides
More how-tos
Rename an S3 file
Amazon S3 has no rename API — keys are immutable. Here's the standard copy + delete pattern, with metadata and tags preserved.
Granular permissions
The IAM s3:prefix Condition that everyone misses, plus when workspace roles are simpler than IAM.
Search inside a bucket
S3 has no search API. Filter by prefix in the current folder, or reach for S3 Inventory + Athena.