Feature toggle

Also called: feature flag, feature switch

Last updated:

A feature toggle is a switch in your code that turns a piece of functionality on or off while the application runs, with no new deploy. Same thing as a feature flag. Some teams say feature switch. Feature toggling means putting new or risky code behind one of these switches, so shipping it to users becomes a configuration change.

Feature toggle vs feature flag

Two names, one technique. "Feature toggle" came first, from Martin Fowler's 2010 write-up and the trunk-based-development crowd that kept using it, while "feature flag" spread later with the hosted products and is the word you'll hear more often now. Some companies say "feature switch" or "feature gate" internally. Choose one and use it everywhere in your own code and docs. Mixed vocabulary breaks search. A teammate grepping for toggle won't find a helper named isFlagOn.

A feature toggle example

Say you're rebuilding checkout and want the new version merged to main weeks before it's finished. The toggle point is one branch:
const showNewCheckout = client.boolVariation('new-checkout', { user_id: user.id }, false)

if (showNewCheckout) {
  renderNewCheckout(cart)
} else {
  renderLegacyCheckout(cart)
}
The last argument is the fallback. Can't evaluate the toggle? Everyone stays on the old checkout. While you build, it's off in production and on in staging so QA can click through the new flow. Once it works you turn it on for your own team, then for 10% of users with a percentage rollout, and finally for everybody, and not one of those steps needs a deploy. After a few quiet weeks at 100%, delete the else branch and the toggle with it.

The four kinds of toggle

Release toggles hide work in progress so a half-finished feature can sit on the main branch without reaching users. They should live for days or weeks. Then they come out. Experiment toggles split traffic to measure which version performs better, and they last as long as the test does. Ops toggles are the kill switches and load shedders an on-call engineer reaches for, and some of those are meant to stay for the life of the system. Permission toggles gate functionality by plan or role, and they are effectively permanent, because they encode a product rule that outlives any one release. The categories come from Pete Hodgson's feature toggles article, and the reason to know which kind you are holding is that only the first two are ever supposed to be removed. Treating a permission toggle as flag debt and deleting it takes a paying customer's feature away.

Toggling a feature without a deploy

How fast a toggle flips depends on where its value lives. With a hard-coded constant, every change is a commit plus a deploy, which defeats the point. Environment variables cut that to a restart. Reading the toggle from a service removes even that. Featureflip's long-running server SDKs hold the configuration in memory, evaluate it locally and receive changes over a streaming connection, so the request right after a dashboard change already sees the new value. It's why an ops toggle works as the kill switch at 2 a.m., with the incident still open.

Feature toggles in Java, JavaScript and Python

The pattern barely changes between languages. You read the toggle where the decision happens and branch on it, passing a default that's safe to serve if the read fails. Featureflip has server SDKs for Java, Node.js, Python, Go, C#, Ruby and PHP, plus client SDKs for the browser, React, Swift, Android and Flutter. The guides to feature flags in Node.js, feature flags in Python and toggling features in React each walk through a full app.

What a feature toggle service does

Most teams build the first version themselves, a boolean in a database row or a JSON file every service reads. A hosted service adds the parts that get awkward later: per-environment values so staging and production can differ, targeting rules so a toggle can be on for one cohort and off for everyone else, a record of who changed what and when, and delivery into running processes within seconds of a change. Feature management is the usual name for that whole layer. Teams switch once a config file can't say who turned this off on Tuesday. Or when the first toggle has to be on for one customer only.

Want the full picture? Read the concept guide: What are feature flags? →

Try it in your own app

The Free plan covers 10 flags and 2 environments. No credit card, no demo call — sign up and ship.