Skip to main content
Wrangler uses a configuration file (typically wrangler.json or wrangler.toml) to define your Worker’s settings, bindings, and deployment options.

Configuration File Formats

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

name
string
required
The name of your Worker. This is used in the Workers dashboard and CLI output.
{
  "name": "my-worker"
}

main

main
string
Path to the entry point of your Worker.
{
  "main": "src/index.ts"
}

compatibility_date

compatibility_date
string
required
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

compatibility_flags
string[]
Flags that enable or disable specific runtime features.
{
  "compatibility_flags": [
    "nodejs_compat",
    "streams_enable_constructors"
  ]
}

account_id

account_id
string
Your Cloudflare account ID.
{
  "account_id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}

Build Configuration

rules

rules
Rule[]
Module import rules for non-JavaScript files.
{
  "rules": [
    {
      "type": "Text",
      "globs": ["**/*.txt"],
      "fallthrough": false
    },
    {
      "type": "Data",
      "globs": ["**/*.bin"]
    }
  ]
}

minify

minify
boolean
Whether to minify the Worker script.
{
  "minify": true
}

define

define
Record<string, string>
Replace global identifiers with constant expressions.
{
  "define": {
    "DEBUG": "false",
    "API_VERSION": "\"v1\""
  }
}

tsconfig

tsconfig
string
Path to a custom TypeScript config file.
{
  "tsconfig": "tsconfig.worker.json"
}

Bindings

vars

vars
Record<string, string>
Environment variables available in your Worker.
{
  "vars": {
    "API_KEY": "my-api-key",
    "ENVIRONMENT": "production"
  }
}

kv_namespaces

kv_namespaces
KVNamespace[]
KV namespace bindings.
{
  "kv_namespaces": [
    {
      "binding": "MY_KV",
      "id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
    }
  ]
}

durable_objects

durable_objects
object
Durable Object bindings.
{
  "durable_objects": {
    "bindings": [
      {
        "name": "MY_DO",
        "class_name": "MyDurableObject",
        "script_name": "do-worker"
      }
    ]
  }
}

r2_buckets

r2_buckets
R2Bucket[]
R2 bucket bindings.
{
  "r2_buckets": [
    {
      "binding": "MY_BUCKET",
      "bucket_name": "my-bucket"
    }
  ]
}

d1_databases

d1_databases
D1Database[]
D1 database bindings.
{
  "d1_databases": [
    {
      "binding": "DB",
      "database_name": "my-database",
      "database_id": "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
    }
  ]
}

queues

queues
object
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
      }
    ]
  }
}

services

services
Service[]
Service bindings to other Workers.
{
  "services": [
    {
      "binding": "AUTH_SERVICE",
      "service": "auth-worker",
      "entrypoint": "AuthAPI"
    }
  ]
}

analytics_engine_datasets

analytics_engine_datasets
AnalyticsEngine[]
Analytics Engine dataset bindings.
{
  "analytics_engine_datasets": [
    {
      "binding": "ANALYTICS"
    }
  ]
}

Routing

routes

routes
Route[]
Routes that trigger your Worker.
{
  "routes": [
    "example.com/*",
    { "pattern": "api.example.com/*", "zone_name": "example.com" }
  ]
}

route

route
string
Single route pattern (alternative to routes).
{
  "route": "example.com/*"
}

Static Assets

assets

assets
object
Configuration for Workers Assets.
{
  "assets": {
    "directory": "./public",
    "binding": "ASSETS",
    "run_worker_first": ["/api/*"]
  }
}

site

site
object
Configuration for Workers Sites (legacy).
{
  "site": {
    "bucket": "./public"
  }
}

Development

dev

dev
object
Local development configuration.
{
  "dev": {
    "port": 8787,
    "local_protocol": "http"
  }
}

Migrations

migrations

migrations
Migration[]
Durable Object migrations.
{
  "migrations": [
    {
      "tag": "v1",
      "new_classes": ["MyDurableObject"]
    },
    {
      "tag": "v2",
      "renamed_classes": [{
        "from": "MyDurableObject",
        "to": "MyDO"
      }]
    }
  ]
}

Observability

logpush

logpush
boolean
Enable Logpush for this Worker.
{
  "logpush": true
}

tail_consumers

tail_consumers
TailConsumer[]
Workers to send tail logs to.
{
  "tail_consumers": [
    {
      "service": "log-processor"
    }
  ]
}

Limits

limits

limits
object
Resource limits for your Worker.
{
  "limits": {
    "cpu_ms": 50
  }
}

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

Build docs developers (and LLMs) love