Simple Boolean Feature Flag Toggle

Create a basic boolean feature flag that turns a feature on or off for all users. The simplest and most common feature flag pattern used in production.

Basic Patterns

Detailed Explanation

Boolean Feature Flag Toggle

The boolean toggle is the most fundamental feature flag pattern. A flag is either true (feature enabled) or false (feature disabled) for all users who evaluate it.

Configuration Example

{
  "dark-mode": {
    "name": "Dark Mode",
    "description": "Enable dark mode theme for all users",
    "type": "boolean",
    "enabled": true,
    "defaultValue": false,
    "targeting": []
  }
}

How It Works

When the flag is enabled with a defaultValue of false, the feature is technically active but defaults to off. This might seem counterintuitive, but it allows you to add targeting rules later without changing the flag state. When you set defaultValue to true, all users see the feature.

Key Considerations

Aspect Detail
Simplicity No targeting rules needed for global on/off
Performance Fastest evaluation since no rules are checked
Fallback Always has a clear fallback value
Use cases Maintenance mode, feature launches, quick rollbacks

LaunchDarkly Equivalent

In LaunchDarkly, this maps to a flag with kind: "boolean" and two variations: [true, false]. The offVariation points to the false variation.

Best Practices

  • Always set a meaningful default value that represents the "safe" state
  • Use descriptive flag keys like enable-dark-mode rather than flag-123
  • Include a description that explains what the flag controls and why it exists
  • Consider adding a cleanup date or ticket reference in the description

Use Case

Launching a new dark mode feature where you want a simple on/off switch. During development, the flag stays off. On launch day, flip the flag to true. If issues arise, immediately flip back to false without deploying code.

Try It — Feature Flag Config Generator

Open full tool