---
title: "Cloudflare R2 - Egress-Free Object Storage"
description: "Scalable, durable, affordable object storage with S3-compatible APIs. Near-infinite scale, zero egress fees, progressive migration, and R2 Data Catalog for analytics."
url: "https://www.cloudflare.com/products/r2"
---

# R2

> Build stateful applications that read and write data globally, integrate directly with Workers, and scale without infrastructure overhead or surprise storage costs.

## Key Features

- Zero egress fees
- S3-compatible API
- Native Workers integration
- Iceberg-compatible Data Catalog
- Progressive migration from existing S3 buckets
- Automatic replication for durability
- Public bucket support for static assets

## Benefits

### Near-infinite scale

Access data from anywhere, create millions of buckets, and write as much data as you need to run your business.

### Sleep better

Don't wake up to a huge egress bill overnight: R2 doesn't charge for egress.

### S3-compatible APIs

R2 exposes S3 compatible APIs: use your existing tools without a rewrite.

### Progressive migration

R2 can sit in front of your legacy object storage provider and progressively copy objects as they are requested, taking the complexity of managing data migration.

### R2 Data Catalog

Use R2's Iceberg-compatible data catalog with your favorite SQL data warehouse to query logs and structured data formats you store in R2.

### Part of Cloudflare Workers

Access your R2 buckets directly from your Workers code without having to juggle API keys and SDKs with a native Workers API.

## Use Cases

### Store application data without egregious egress fees

Download your data from R2 without worrying that your egress bill is scaling 1:1 with your growth. Store and access user content, AI training data, logs and columnar data without breaking the bank.

### Store AI datasets and model artifacts

Keep training data, model weights, and analytics datasets accessible from any cloud provider without transfer fees. Data portability enables better infrastructure choices.

### Break free from cloud vendor lock-in

Store your data neutrally and access it from any cloud provider for compute workloads. Choose the best tools without being trapped by transfer costs.

### Migration without the risk

Configure R2 to pull objects from your existing object storage provider as they are requested, allowing you to switch to R2 without having to manage large-scale data migration and benefit from zero-egress fees immediately.

## Code Examples

### S3-compatible

R2's S3 compatible API means that you can easily migrate to R2 without having to rewrite your code or change the tools your team is using.

```python
import boto3

s3 = boto3.resource('s3',
  endpoint_url = 'https://{your-account-id}.r2.cloudflarestorage.com',
  aws_access_key_id = '{access_key_id}',
  aws_secret_access_key = '{access_key_secret}'
)
```

### Build applications using Workers and R2

Straightforward APIs that allow you directly access R2 from Cloudflare Workers.

```typescript
export default {
	async fetch(request, env) {
		let key = new URL(request.url).searchParams.get("key");
		// Write an object to R2 directly
		await env.MY_BUCKET.put(key, request.body);

		// Fetch an object (or objects!) using the Workers API:
		const object = await env.MY_BUCKET.get(key);
		return new Response(object);
	},
};
```

### Query Data in R2

Use R2's native Iceberg-compatible [Data Catalog](https://developers.cloudflare.com/r2/data-catalog/) to manage schemas and query structured data stored in R2 with your favorite query engine or ETL tool, including DuckDB, Spark, Trino or Snowflake.

```sql
-- Install the iceberg DuckDB extension and load the extension.
INSTALL iceberg;
LOAD iceberg;

-- Create a DuckDB secret to store R2 Data Catalog credentials.
CREATE SECRET r2_secret (
    TYPE ICEBERG,
    TOKEN '<token>'
);

-- Attach your R2 Data Catalog
ATTACH '<warehouse_name>' AS prod_analytics_data (
    TYPE ICEBERG,
    ENDPOINT '<catalog_uri>'
);

-- Show all available tables.
SHOW ALL TABLES;

-- Query your Iceberg table.
SELECT * FROM prod_analytics_data.default.user_events;
```

## Resources

- [Full Documentation](https://developers.cloudflare.com/r2): Complete technical documentation
- [Get Started](https://dash.cloudflare.com/sign-up): Sign up and start building
- [Pricing](/plans.md): See pricing details

## Related Products

- [Artifacts](/products/artifacts.md): Git-native versioned storage
- [Cache Reserve](/products/cache-reserve.md): Persistent caching for static content
- [D1](/products/d1.md): Serverless SQL
- [Data Platform](/products/data-platform.md): Ingest, Catalog & Query

---

*This is a markdown version of [https://www.cloudflare.com/products/r2](https://www.cloudflare.com/products/r2) for AI/LLM consumption.*
