Guides

# Kill switches and feature toggles

A worked example of feature flags as plain JSON, with a schema that keeps them safe.

In hotcfg, feature flags are one JSON document your app reads. (Overrides by platform, build number or rollout percentage work with a jq filter: see [version targeting](https://hotcfg.run/docs/recipes/version-targeting).) That covers most of what teams use flags for: turning a feature on, turning a broken one off, and changing a limit or a price.

## The config

flags.json

```
{
  "features": { "checkout_v2": false, "new_onboarding": true },
  "kill": { "image_uploads": false },
  "limits": { "max_upload_mb": 25 },
  "min_supported_version": "4.2.0"
}
```

## A schema that keeps it safe

Require every key the app reads, and give each a type. A flag can then never be missing or the wrong type in production.

schema.json

```
{
  "type": "object",
  "required": ["features", "kill", "limits", "min_supported_version"],
  "properties": {
    "features": { "type": "object", "additionalProperties": { "type": "boolean" } },
    "kill": { "type": "object", "additionalProperties": { "type": "boolean" } },
    "limits": {
      "type": "object",
      "required": ["max_upload_mb"],
      "properties": { "max_upload_mb": { "type": "integer", "minimum": 1, "maximum": 500 } }
    },
    "min_supported_version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" }
  }
}
```

## In the app

Load the config with the [fetch code](https://hotcfg.run/docs/guides/fetching), then read flags with a default for anything missing:

Swift

```
let config = (try? JSONSerialization.jsonObject(with: await HotcfgConfig.load())) as? [String: Any] ?? [:]
let kill = config["kill"] as? [String: Bool] ?? [:]
if kill["image_uploads"] == true { hideUploadButton() }
```

## Flipping a kill switch

Change the value and publish to production, from the dashboard or the CLI. For complete apps, see the [iOS kill switch](https://hotcfg.run/docs/recipes/ios-killswitch), [React Native maintenance mode](https://hotcfg.run/docs/recipes/react-native-maintenance) and [Godot](https://hotcfg.run/docs/recipes/godot) recipes. Every app sees it on its next fetch. When the fix ships, flip it back, or [roll back](https://hotcfg.run/docs/guides/environments) to the version before.

Last updated 10 November 2026
