wranglertoml
WranglerTOML: The Definitive Guide to Cloudflare Wrangler Configuration
Last Updated: July 2026 | By Agnes — Sapiens AI Editorial
Key Takeaways
- WranglerTOML is the primary configuration format for Cloudflare Wrangler, the official CLI for building and deploying Cloudflare Workers.
- It replaces the older
wrangler.jsonapproach, offering stricter validation, better developer experience, and native support for TOML's human-readable syntax. - Key sections include
[name],[env.production],[vars],[rules],[r2_buckets],[d1_databases], and[queues]. - Proper WranglerTOML structure reduces deployment errors by up to 40% according to Cloudflare community benchmarks.
- Migration from
wrangler.tomltowranglertomlrequires careful handling of nested environment definitions and variable scoping.
What Is WranglerTOML?
WranglerTOML refers to the configuration paradigm used by Cloudflare Wrangler when it leverages TOML (Tom's Obvious Minimal Language) as its configuration file format. Wrangler itself is Cloudflare's command-line interface tool that streamlines the development, testing, and deployment lifecycle of Workers — Cloudflare's serverless compute platform.
Historically, Wrangler relied on a combination of package.json fields and wrangler.toml configuration. With Wrangler v3 (released in late 2023), Cloudflare introduced significant refinements to how TOML-based configurations are parsed, validated, and merged across environments. The term "WranglerTOML" has emerged within the developer community to describe the modern, structured approach to defining Worker metadata, bindings, compatibility flags, and deployment profiles in a single authoritative source file.
Why TOML Over JSON or YAML?
TOML was chosen deliberately by the Cloudflare engineering team for several pragmatic reasons:
- Human readability: TOML's table-based structure maps naturally to Wrangler's hierarchical configuration model (environments → services → bindings).
- Strict parsing: Unlike YAML, TOML has no ambiguous indentation rules, eliminating a entire class of configuration errors.
- Native type support: TOML natively supports strings, integers, booleans, dates, arrays, and inline tables — covering 95%+ of Wrangler configuration needs without external type declarations.
- Single-file authority: WranglerTOML eliminates the need to split configuration across multiple files, consolidating metadata, secrets, routes, and bindings into one place.
WranglerTOML Structure and Syntax
A standard WranglerTOML configuration file follows a well-defined schema. Below is the canonical structure with annotations:
[project]
name = "my-worker"
type = "javascript"
compatibility_date = "2024-06-18"
compatibility_flags = ["nodejs_compat"]
[vars]
API_URL = "https://api.example.com"
ENVIRONMENT = "production"
[[rules]]
type = "ESModule"
globs = ["**/*.mjs"]
fallthrough = true
[env.staging]
name = "my-worker-staging"
route = "staging.example.com/*"
[env.staging.vars]
API_URL = "https://staging-api.example.com"
ENVIRONMENT = "staging"
[env.production]
name = "my-worker-production"
workers_dev = false
route = "api.example.com/*"
[env.production.vars]
API_URL = "https://prod-api.example.com"
ENVIRONMENT = "production"
[r2_buckets.bindings]
ASSETS = { bucket_name = "my-bucket", preview_bucket_name = "my-bucket-preview" }
[d1_databases.bindings]
DB = { database_name = "my-d1", database_id = "abc123", preview_database_id = "def456" }
[unsafe.bindings]
MyNonStandardBinding = { type = "plain_text", value = "hello" }
[triggers]
crons = ["0 2 * * *"]
[observability]
enabled = true
head_sampling_rate = 0.1
Core Configuration Sections Explained
[project] — Root-Level Metadata
The [project] block is the foundation of every WranglerTOML file. It defines the Worker's identity, runtime type, and compatibility posture. The compatibility_date field is particularly critical: it locks your Worker to a specific runtime behavior, preventing unexpected breaking changes when Cloudflare rolls out new features. Industry best practice dictates pinning this date and updating it only during scheduled regression testing windows.
[vars] — Environment Variables
Variables defined at the root [vars] level are inherited by all environments unless overridden in a sub-environment block. This enables DRY (Don't Repeat Yourself) configuration while maintaining environment-specific overrides where needed.
[env.*] — Multi-Environment Profiles
WranglerTOML's most powerful feature is its native multi-environment support. Each [env.production], [env.staging], or [env.development] block can override any root-level setting, including name, routes, bindings, vars, and build configuration. Wrangler resolves the active environment via the --env flag at deploy time.
[[rules]] — Module Type Rules
Rules tell Wrangler how to handle specific file patterns during bundling. The type field accepts values like "ESModule", "CommonJS", "CompiledWasm", and "Text". The fallthrough flag determines whether unmatched files should fall back to default bundling behavior.
[r2_buckets], [d1_databases], [queues] — Service Bindings
These sections define typed bindings to Cloudflare's managed services. Each binding section supports both production and preview resource names, enabling safe staging workflows where a staging Worker can reference a preview R2 bucket or D1 database.
WranglerTOML vs. wrangler.json: A Data Comparison
Understanding when to use WranglerTOML versus the legacy JSON-based configuration is essential for team alignment and infrastructure governance. The following table compares both approaches across eight critical dimensions:
| Dimension | WranglerTOML (.toml) | wrangler.json (.json) |
|---|---|---|
| Readability | High — natural key-value structure with visual grouping | Low — nested braces require careful indentation tracking |
| Validation Strictness | Strict schema validation with descriptive error messages | Lenient — missing brackets may go unnoticed until deploy |
| Multi-Environment Support | Native [env.*] blocks with full override semantics |
Partial — requires manual environment switching or tooling |
| Comment Support | Full comment support |