Wrangler uses a configuration file (typically wrangler.json or wrangler.toml) to define your Worker’s settings, bindings, and deployment options.
Wrangler supports two configuration formats:
- JSONC (
.json or .jsonc): JSON with comments
- TOML (
.toml): Tom’s Obvious Minimal Language
For new projects, we recommend using JSONC format for better IDE support and validation.
Core Configuration
name
The name of your Worker. This is used in the Workers dashboard and CLI output.
main
Path to the entry point of your Worker.{
"main": "src/index.ts"
}
compatibility_date
A date in the form yyyy-mm-dd that specifies which version of the Workers runtime to use.{
"compatibility_date": "2024-01-01"
}
compatibility_flags
Flags that enable or disable specific runtime features.{
"compatibility_flags": [
"nodejs_compat",
"streams_enable_constructors"
]
}
account_id
Your Cloudflare account ID.{
"account_id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
Build Configuration
rules
Module import rules for non-JavaScript files.{
"rules": [
{
"type": "Text",
"globs": ["**/*.txt"],
"fallthrough": false
},
{
"type": "Data",
"globs": ["**/*.bin"]
}
]
}
ESModule - JavaScript/TypeScript modules
CommonJS - CommonJS modules
Text - Text files as strings
Data - Binary data as ArrayBuffer
CompiledWasm - WebAssembly modules
minify
Whether to minify the Worker script.
define
Replace global identifiers with constant expressions.{
"define": {
"DEBUG": "false",
"API_VERSION": "\"v1\""
}
}
tsconfig
Path to a custom TypeScript config file.{
"tsconfig": "tsconfig.worker.json"
}
Bindings
vars
Environment variables available in your Worker.{
"vars": {
"API_KEY": "my-api-key",
"ENVIRONMENT": "production"
}
}
kv_namespaces
KV namespace bindings.{
"kv_namespaces": [
{
"binding": "MY_KV",
"id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
]
}
Show KVNamespace properties
Variable name to access the namespace
KV namespace ID for local development
durable_objects
Durable Object bindings.{
"durable_objects": {
"bindings": [
{
"name": "MY_DO",
"class_name": "MyDurableObject",
"script_name": "do-worker"
}
]
}
}
Variable name to access the namespace
Exported Durable Object class name
Name of the Worker that defines this Durable Object (if different from current)
Environment of the script (production/staging)
r2_buckets
R2 bucket bindings.{
"r2_buckets": [
{
"binding": "MY_BUCKET",
"bucket_name": "my-bucket"
}
]
}
Variable name to access the bucket
Bucket name for local development
Jurisdiction for the bucket (e.g., “eu”)
d1_databases
D1 database bindings.{
"d1_databases": [
{
"binding": "DB",
"database_name": "my-database",
"database_id": "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
}
]
}
Show D1Database properties
Variable name to access the database
queues
Queue bindings for producers and consumers.{
"queues": {
"producers": [
{
"binding": "MY_QUEUE",
"queue": "my-queue"
}
],
"consumers": [
{
"queue": "my-queue",
"max_batch_size": 10,
"max_batch_timeout": 5
}
]
}
}
Variable name for the queue
Queue name to consume from
Maximum messages per batch (default: 10, max: 100)
Maximum seconds to wait before dispatching batch (default: 5)
Number of retries on failure (default: 3)
Queue to send failed messages to
services
Service bindings to other Workers.{
"services": [
{
"binding": "AUTH_SERVICE",
"service": "auth-worker",
"entrypoint": "AuthAPI"
}
]
}
Variable name for the service
Name of the Worker to bind to
Environment of the service
analytics_engine_datasets
analytics_engine_datasets
Analytics Engine dataset bindings.{
"analytics_engine_datasets": [
{
"binding": "ANALYTICS"
}
]
}
Routing
routes
Routes that trigger your Worker.{
"routes": [
"example.com/*",
{ "pattern": "api.example.com/*", "zone_name": "example.com" }
]
}
route
Single route pattern (alternative to routes).{
"route": "example.com/*"
}
Static Assets
assets
Configuration for Workers Assets.{
"assets": {
"directory": "./public",
"binding": "ASSETS",
"run_worker_first": ["/api/*"]
}
}
Directory containing static files
Variable name for the assets binding
URL patterns to run Worker logic before serving assets
site
Configuration for Workers Sites (legacy).{
"site": {
"bucket": "./public"
}
}
Development
dev
Local development configuration.{
"dev": {
"port": 8787,
"local_protocol": "http"
}
}
Port to run dev server on
Protocol for local server
Protocol for upstream requests
Migrations
migrations
Durable Object migrations.{
"migrations": [
{
"tag": "v1",
"new_classes": ["MyDurableObject"]
},
{
"tag": "v2",
"renamed_classes": [{
"from": "MyDurableObject",
"to": "MyDO"
}]
}
]
}
Show Migration properties
Unique identifier for this migration
Durable Object classes being added
Observability
logpush
Enable Logpush for this Worker.
tail_consumers
Workers to send tail logs to.{
"tail_consumers": [
{
"service": "log-processor"
}
]
}
Limits
limits
Resource limits for your Worker.{
"limits": {
"cpu_ms": 50
}
}
Maximum CPU time in milliseconds
Environment Overrides
You can define environment-specific overrides:
{
"name": "my-worker",
"vars": {
"ENVIRONMENT": "production"
},
"env": {
"staging": {
"vars": {
"ENVIRONMENT": "staging"
},
"kv_namespaces": [
{
"binding": "MY_KV",
"id": "staging-kv-id"
}
]
}
}
}
Deploy to staging:
wrangler deploy --env staging