How to delete a file from S3 safely
Run `aws s3 rm s3://bucket/key`, or right-click → Delete in S3 Viewer. The catch: if the bucket has versioning enabled, this only adds a delete marker — the prior version is still there and still billed. To actually purge a versioned object, delete each version explicitly with its version ID. For bulk delete, S3 Viewer wraps the DeleteObjects API so you can clear up to 1,000 keys in a single call. If MFA Delete is enabled, you'll need an MFA token.
Step-by-step.
- 01
In S3 Viewer: right-click → Delete
Multi-select to bulk delete across many keys in a singleDeleteObjectscall (the S3 API supports up to 1,000 keys per request). The confirmation shows the count and total size before it commits. - 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 bucket owner's MFA token. Plan accordingly — this is on by design for compliance buckets.
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 surfaces version state in the UI and prompts you when versioning is on, so you know whether your “delete” is a soft delete (delete marker) or a hard one. For bulk delete, S3 Viewer wraps the DeleteObjects API (up to 1,000 keys per call) — multi-select a range and clear them in one round trip.
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?
Skip the CLI. Try it in the browser.
S3 Viewer turns the steps above into a single click. Open source, self-hostable, free for personal use.
Why teams pick this
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 across buckets
How to actually search S3 with Tab autocomplete, and when S3 Inventory + Athena is the right pattern.