> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating flag variations

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

This topic explains how to create and edit your feature flag's variations and outlines the different types of flag variations.

Feature flag variations determine what a context or user receives when they encounter a feature flag.

Some aspects of flags are consistent across environments, and others are environment-specific:

* A flag's variations and variation values are consistent across all environments in a project. For example, if a flag has three variations of A, B, and C, those three variations appear in all environments within your project. If you add a new flag variation, it is immediately available in all environments.
* Flag targeting rules are environment-specific. If you change the default targeting rule to serve a different variation, the targeting change only applies to the current environment, such as Staging or Production. To learn more, read [Configure the same flag in different environments](/docs/home/flags/new#configure-the-same-flag-in-different-environments).

<Card icon="rectangle-terminal" horizontal>
  Try it in your SDK: [Flag variation evaluation](/docs/sdk/features/evaluating)
</Card>

## Flag variations

LaunchDarkly supports boolean and multivariate flags. From the flag's **Variations** tab, you can add, edit, or delete variations of existing flags:

* Boolean flags have two variations: `true` or `false`.
* [Multivariate flags](#multivariate-flags) can have two or more string, number, or JSON variations, depending on the flag type you choose when you create it.

<Note>
  **Changing variation types**

  After you create a feature flag, you cannot change its variation type. For example, you cannot edit a feature flag that returns numbers to make it return strings instead. To learn more about creating flags, read [Creating new flags](/docs/home/flags/new).
</Note>

Here is the **Variations** tab of a multivariate flag:

<Frame caption="The &#x22;Variations&#x22; tab of a flag.">
  <img src="https://mintcdn.com/launchdarkly/hutarVphEq2dY_zb/images/auto/flag-variations.auto.png?fit=max&auto=format&n=hutarVphEq2dY_zb&q=85&s=da652d71ee09f59266c0bad8f5cc2c38" alt="The &#x22;Variations&#x22; tab of a flag." width="2010" height="1488" data-path="images/auto/flag-variations.auto.png" />
</Frame>

## Edit flag variations

When you add, delete, or edit a feature flag's variations, the change impacts all environments within the project.

### Add new variations

To add a new variation to an existing string, number, or JSON flag:

1. Navigate to the flag's **Variations** tab.
2. Click **New variation**.
3. Add a **Name**, **Description**, and **Value**.
4. Click **Review and save**.

### Delete existing variations

To delete a variation for an existing string, number, or JSON flag:

1. Navigate to the flag's **Variations** tab.
2. Click **New variation**.
3. Click **Delete** next to the variation you want to remove.
4. Click **Review and save**.

### Edit existing variations

To edit a flag's variation values:

1. Navigate to the flag's **Variations** tab.
2. Make any variation changes as needed:
   * For boolean flags, you can edit the **Name** and **Description**.
   * For number, string, and JSON flags, you can edit the **Value**, **Name**, and **Description**.
3. Click **Review and save**.

Editing the value of a flag variation in use can impact the contexts receiving that variation. If you edit the value of a variation that is actively in use, a warning displays with information about the variation and the environments it's used in:

<Frame caption="A warning that a flag variation is in use.">
  <img src="https://mintcdn.com/launchdarkly/7dOLLfhGme_BglBp/images/__LD_UI_no_test/variations-in-use.png?fit=max&auto=format&n=7dOLLfhGme_BglBp&q=85&s=d434959fd273ef6aea17d7b03457d786" alt="A warning that a flag variation is in use." width="1612" height="546" data-path="images/__LD_UI_no_test/variations-in-use.png" />
</Frame>

A flag variation is considered in use in a particular environment when:

* you have configured the flag to serve that variation to some or all contexts, and
* the flag is actively being evaluated in that environment, with a [status of "active" or "launched."](/docs/home/flags/flag-status#flag-status-definitions)

<Danger>
  **Deleting variations**

  When you delete a variation, individual targeting and custom rules that return that variation are also deleted. If a custom rule has a percentage rollout, the rollout for that variation is set to zero. If the default rule returns the deleted variation, it will change to return the default off value instead.

  LaunchDarkly allows you to delete variations that are designated to be served when targeting is off. Make sure that your application is able to handle a null value when targeting is off in case this happens.
</Danger>

## Change default flag values

When you create a feature flag, some of its values are designated as defaults. A flag's default values are the values that are served when targeting is on or off, unless you specify otherwise. The default value when a flag is **On** can be either a single variation or a rollout. The default value when a flag is **Off** can be only a single variation.

For example, a boolean flag could have `true` set as its default rule when on and `false` set as its default off variation. A multivariate flag could have `variation 2` set as its default rule when on and `variation 1` set as its default off variation, with `variation 3` and `variation 4` configured to appear when contexts match certain targeting rules.

Default values are designated automatically every time you create a feature flag. You can accept the default values or change them. When you change the default values and save a flag, you create the flag across all environments in your project with these values set as its defaults.

Here is an image of a flag's default values:

<Frame caption="The default variations when creating a flag.">
  <img src="https://mintcdn.com/launchdarkly/hutarVphEq2dY_zb/images/auto/flag-create-default-variations.auto.png?fit=max&auto=format&n=hutarVphEq2dY_zb&q=85&s=67933252cacba12c1bc1b719ee5eeb43" alt="The default variations when creating a flag." width="956" height="366" data-path="images/auto/flag-create-default-variations.auto.png" />
</Frame>

To change a flag's default values for new environments:

1. Click the **pencil** icon next to "Variations" in the flag's right sidebar. The **Variations** tab opens.
2. In the "Default variations for new environments" section, update the variations as needed.
3. Click **Review and save**.

<Note>
  **Editing default values only impacts new environments**

  If you modify a flag's default values, the updated defaults only apply to new environments. You can not change the default values in environments that already exist.
</Note>

## Multivariate flags

Multivariate flags let you use one flag to serve more than two variations of a feature simultaneously. There is no limit to the number of variations you can add to a multivariate flag, making it useful for complex use cases and for managing multiple variations of a feature.

<Warning>
  **Do not edit flag variations that are in use**

  Do not edit the values of flag variations that are in use. Flag variations are global across all environments within a project. This means that editing the value of a flag variation can have unexpected consequences in other environments, particularly your production environments.

  Instead, create a new variation with the new value, and update your targeting rules to serve the new variation where needed.
</Warning>

Multivariate flag variation types include string, number, and JSON. To learn more, read [Understanding flag types](/docs/sdk/concepts/flag-types#understanding-flag-types) in the SDK documentation.

You can use multivariate flags to target multiple sets of contexts and provide different variations to each. In the following example, the first rule serves `Two-click checkout` to all customers whose country is `US`. The second rule serves `One-click checkout` to all customers whose email ends with `.edu`. All customers not targeted in the custom rules are served the default rule.

Here is an image of a flag with custom rules:

<Frame caption="A multivariate flag with custom rules.">
  <img src="https://mintcdn.com/launchdarkly/hutarVphEq2dY_zb/images/auto/flag-variations-multivariate-targeting.auto.png?fit=max&auto=format&n=hutarVphEq2dY_zb&q=85&s=7c491eadb18b2c399988e115f0764a53" alt="A multivariate flag with custom rules." width="1882" height="780" data-path="images/auto/flag-variations-multivariate-targeting.auto.png" />
</Frame>

To learn more about targeting rules, read [Target with flags](/docs/home/flags/target).

You can also use multivariate flags to perform testing with LaunchDarkly Experimentation. To learn more, read [Creating Experiments](/docs/home/experimentation/create).

### JSON schema for multivariate flag variations

You can use a JSON schema to validate multivariate flag variations to help ensure type safety, enforce naming conventions, and restrict value options for specific fields.

To use a JSON schema for a new flag, click the **Schema** button in the flag creation dialog:

<Frame caption="The schema option in the flag creation dialog.">
  <img src="https://mintcdn.com/launchdarkly/nJ-98AdUTCC7b8MD/images/auto/flag-create-schema.auto.png?fit=max&auto=format&n=nJ-98AdUTCC7b8MD&q=85&s=5e6af1b9c9af51e106ebcad824bce8ff" alt="The schema option in the flag creation dialog." width="1540" height="1234" data-path="images/auto/flag-create-schema.auto.png" />
</Frame>

A "Schema validation" section appears. Click the **magic wand** icon to suggest a JSON schema based on your existing variation values. Click the **broom** icon to format the JSON schema.

After you save the new flag, LaunchDarkly validates the flag's individual variation values against the schema.

To add a JSON schema to an existing flag, navigate to its **Variations** tab and click **Add schema**.

<Tip>
  **Looking for information on how to configure flag targeting using JSON?**

  To learn how to use JSON to configure flag targeting, read [JSON targeting](/docs/home/flags/json-targeting).
</Tip>
