Flag types

Overview

This topic explains the four types of feature flags and when to use them. When you create a flag, you can choose from four different flag types for different common use cases.

The four flag types include boolean, string, number, and JSON.

When you choose a flag type, you should choose one whose variations are the same data type as the value your code returns.

Boolean flags

Boolean flags are the most common and simple flag type, having two possible variations: true or false.

Boolean flags can be used for on/off switches, new feature rollouts, or anything that requires a binary option.

You can change the name and description of boolean flag variations, but you can’t change the variation values, and you can’t add more than two variations.

String flags

String flag variations hold simple configuration values instead of booleans. They are multivariate flags, meaning they can have more than two variations.

String flags can be used for things like switching between different versions of header text, URLs, or other configurations.

String flags have a size limit of 32KB. Strings are UTF-8 encoded, so certain characters, such as emojis and non-ASCII characters, take more than one byte each.

You can use escape sequences in string values. For example, LaunchDarkly treats string values ab\u0063 and abc as the same value.

Number flags

Number flag variations hold numerical integer or floating point values. They are multivariate flags, meaning they can have more than two variations.

Number flags are useful for numerical configuration parameters, such as thresholds or timeouts.

Some LaunchDarkly SDKs treat certain types of number variations slightly differently. To learn more, read the SDK topic on Number flags.

JSON flags

JSON flag variations hold structured data as a JSON object or array. They are multivariate flags, meaning they can have more than two variations. JSON flags have a size limit of 32KB.

JSON flags are useful when you need to bundle multiple related values within a single variation, such as settings for a UI layout or an API response.

You can treat an optional array or object property as empty if no property value is present. You can write an empty array as [], an empty object as {}, or omit the property completely.

Flag types and SDKs

To learn how LaunchDarkly SDKs interact with different flag types, read Using flag types.