What are feature flags? Explained with light switches
A feature flag is an on/off switch built into software: new code goes live with the feature hidden, then the team turns it on, off, or on for some customers. Like a separate light switch for each room.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- DevOps
In one sentence: A feature flag is an on/off switch built into software, so a team can put new code live with the feature hidden, then turn it on, off, or on for only some customers, without installing a new version.
The everyday picture
Picture a house where every room has its own light switch. When the builders add a new room, they can finish the wiring and close the walls while the switch stays off. The room is there, but nobody walks into a dark, half-ready space.
When the room is ready, someone flips the switch and the light comes on. Nobody has to call the builders back or open the walls again. If the new light starts to flicker, the switch goes off in a second, and the rest of the house carries on as normal.
A feature flag is that switch, for one feature in your software. A widely used guide on Martin Fowler's website describes them as a way to change how a system behaves without changing its code.
New code goes live with its feature switched off. The team turns it on when ready, for everyone or only some customers, and can turn it off again without redeploying.
How it works, step by step
- The team writes the new feature (the builders add a new room). Around it, they place a simple question in the code: is this feature's switch on?
- The code is deployed with the flag off (the room is wired in, light off). The new version goes live, but customers still see the old behaviour. AWS describes this as deploying code that stays hidden until you are ready to release it.
- A flag setting holds the answer (the switch on the wall). The setting lives outside the code, often in a flag service with a dashboard, so it can change without a new deployment.
- Each time the feature could appear, the software checks the switch (someone reaches the room and sees if the light is on). The check can also use rules, such as "only staff" or "only customers in one country". The OpenFeature standard calls this targeting.
- The team flips the switch (the light goes on, or off). They turn the feature on when it is ready. If something goes wrong, they turn it off at once, without rolling back the whole deployment.
Try it · Myth or fact
Feature flags: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
Teams use these switches for different jobs. That guide lists release flags that hide unfinished work, experiment flags that show two versions to compare them, operations flags that switch off a heavy feature when the system is under strain, and permission flags that give some customers features others do not have, such as a paid plan.
Where the picture stops
- A light switch is the same for everyone in the house. A feature flag can be on for some customers and off for others at the same moment, for example a small share of users first, then more.
- An extra switch on the wall costs nothing. Every flag in software adds another path through the code to test and maintain. The same guide advises removing release flags once the feature is fully live, and says they should usually last only a week or two.
- Flipping a switch only controls the light. Turning a flag off hides the feature, but it does not undo changes the feature already made, such as data it saved while it was on.
Why it matters for your business
- Lower risk at launch: a problem feature can be switched off immediately, instead of waiting for the team to prepare and deploy an older version.
- Launch on your schedule: the code can go live quietly days earlier, and the feature appears when marketing or sales are ready, at the flip of a switch.
- Learn from real customers safely: showing a new feature to a small group first lets you watch how it behaves and expand it gradually, as AWS describes in its feature flag guidance.
- A cost to manage: old flags left in place make software harder to test and change, so ask your team how and when they remove them.
An example
Imagine a 15-person online furniture shop building a new "pay in instalments" option. The developers deploy the code on Monday with its flag off, so customers notice nothing. On Wednesday the owner turns it on for staff accounts only, and they test real orders. The next week it goes on for a small share of customers. When one card type shows errors, the team switches the flag off within a minute, fixes the problem, and turns it back on. Once everyone has it and it works well, the team removes the flag from the code.
Frequently asked questions
Is a feature flag the same as a feature toggle?
Yes. Feature flag, feature toggle and feature switch are names for the same idea. Different companies and tools simply prefer different words.
Do feature flags replace testing?
No. The feature still needs testing before it is switched on. Flags add work for testers, because the software must behave correctly with the switch both on and off.
Can non-technical staff flip a feature flag?
Often, yes. Many flag services have a dashboard where a product manager can turn a feature on for chosen customers, as long as the team has set up the right access and approvals.
What is a kill switch?
A kill switch is a flag kept on purpose to turn a feature off quickly in an emergency, for example when part of the system is overloaded. Unlike release flags, these can stay for a long time.
Related explainers
The DevDrift sets up cloud releases with feature switches, monitoring and quick rollbacks: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.