[ Web Proxy ]
URL:
Viewing: https://developers.cloudflare.com/r2/objects/delete-objects/#delete-a-folder [Back]  [Original]

Delete objects Cloudflare R2 docsSkip to content
SearchCtrlKLog in
  1. Home
  2. /R2
  3. /Objects
  4. /Delete objects

Delete objects

Last updated Apr 30, 2026Copy as MarkdownView as MarkdownAgent setup
OverviewDelete via dashboardDelete via Workers APIDelete via S3 APIDelete via WranglerRelated resources

You can delete objects from R2 using the dashboard, Workers API, S3 API, or command-line tools. To empty or delete an entire bucket, refer to Delete buckets.

Delete via dashboard

  1. In the Cloudflare dashboard, go to the R2 object storage page.

    Go to Overview ↗
  2. Select your bucket.

  3. (Optional) Select the View prefixes as directories checkbox to view prefixes grouped as folders.

  4. Select the objects or folders you want to delete. You can select a mix of both in the same operation.

  5. Select Delete.

  6. Confirm your choice in the dialog that appears.

To delete all objects in a bucket at once, refer to Empty a bucket.

Delete via Workers API

Use R2 bindings in Workers to delete objects:

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext) {
		await env.MY_BUCKET.delete("image.png");
		return new Response("Deleted");
	},
} satisfies ExportedHandler<Env>;

For complete documentation, refer to Workers API.

Delete via S3 API

Use S3-compatible SDKs to delete objects. You'll need your account ID and R2 API token.

import { S3Client, DeleteObjectCommand } from "@aws-sdk/client-s3";

const S3 = new S3Client({
	region: "auto", // Required by SDK but not used by R2
	// Provide your Cloudflare account ID
	endpoint: `https://<ACCOUNT_ID>.r2.cloudflarestorage.com`,
	// Retrieve your S3 API credentials for your R2 bucket via API tokens (see: https://developers.cloudflare.com/r2/api/tokens)
	credentials: {
		accessKeyId: '<ACCESS_KEY_ID>',
		secretAccessKey: '<SECRET_ACCESS_KEY>',
	},
});

await S3.send(
	new DeleteObjectCommand({
		Bucket: "my-bucket",
		Key: "image.png",
	}),
);
import boto3

s3 = boto3.client(
	service_name="s3",
	# Provide your Cloudflare account ID
	endpoint_url=f"https://{ACCOUNT_ID}.r2.cloudflarestorage.com",
	# Retrieve your S3 API credentials for your R2 bucket via API tokens (see: https://developers.cloudflare.com/r2/api/tokens)
	aws_access_key_id=ACCESS_KEY_ID,
	aws_secret_access_key=SECRET_ACCESS_KEY,
	region_name="auto", # Required by SDK but not used by R2
)

s3.delete_object(Bucket="my-bucket", Key="image.png")

For complete S3 API documentation, refer to S3 API.

Delete via Wrangler

Caution

Deleting objects from a bucket is irreversible.

Use Wrangler to delete objects. Run the r2 object delete command:

wrangler r2 object delete test-bucket/image.png

Delete buckets

Empty all objects from a bucket and permanently delete it.

Bucket locks

Protect objects from accidental deletion with retention policies.

Object lifecycles

Automatically expire objects after a specified period.
PreviousDownload objectsNextOverview

Was this helpful?

YesNo
Edit pageReport issue
[]

Web Proxy Viewer  |  New URL  |  Original Page