# Feature Flag

> A switch in your code. It turns a feature on or off with no deploy.

**Field:** Software Development  
**Category:** DevOps & Cloud  
**Also known as:** Feature Toggle, Feature Switch, Flag

## Think of it like

Think of it like a light switch on the wall. The wiring is already in, and you choose when to turn it on.

## Definition

A feature flag is an on and off switch in your code that hides or shows a feature. The new code ships switched off. You can then turn it on for your team, then for 10 percent of users, then everyone. If it goes wrong, you flip it off in seconds. Old flags should be removed, or the code fills up with dead switches.

## Example

Emma ships a new search page behind a flag. She turns it on for staff only, finds a bug, fixes it, and then turns it on for everyone.

## Example code

```javascript
if (flags.isOn('new-search', user)) {
  showNewSearch();
} else {
  showOldSearch();
}
```

The same code serves both versions, and the flag decides who sees which.

## Why it matters

It splits shipping code from turning it on. You can deploy any time and release when it suits you.

## Common mistake

Leaving flags in the code for years. Each one doubles the paths to test, so remove a flag once it is fully on.

## Three principles

- **Ship it off.** Turn it on later.
- **Pick who sees it.** Staff, a share, everyone.
- **Clean up.** Remove old flags.

## Related terms

- [Continuous Deployment](https://learn.benibix.com/term/development/continuous-deployment)
- [Canary Release](https://learn.benibix.com/term/development/canary-release)
- [Deployment (Software)](https://learn.benibix.com/term/development/deployment)
- [Release (Software)](https://learn.benibix.com/term/development/release)
- [Trunk-Based Development](https://learn.benibix.com/term/development/trunk-based-development)

## Told apart from

- [Canary Release vs Feature Flag](https://learn.benibix.com/compare/canary-release-vs-feature-flag): People think a canary release is the same as a feature flag, since both can start with 5% of users, and it is not. A canary sends some users to a new version of the whole app, on its own servers. A flag is a switch inside the code that turns one feature on for some users. A canary tests a deploy. A flag tests a feature.
- [Feature Flag vs Rollback](https://learn.benibix.com/compare/feature-flag-vs-rollback): People think turning off a feature flag is a rollback, and it is not. A rollback puts the whole last version back on the servers, which takes a minute or two. Turning off a flag hides one feature in seconds and leaves the rest of the deploy in place. Use the flag when one feature is the problem, and roll back when the whole deploy is.

## Taught in

- [Git Branching Strategies](https://learn.benibix.com/learn/development-version-control/git-branching-strategies): Git and GitHub, 13/13
- [Feature Launch and Adoption](https://learn.benibix.com/learn/business-product-management/feature-launch-and-adoption): Product Management, 11/13

---

Source: https://learn.benibix.com/term/development/feature-flag
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
