---
id: iso-3166
title: ISO3166
pagination_label: ISO3166
sidebar_label: ISO3166
sidebar_class_name: iso3166
keywords: ['transforms', 'operations', 'iso3166']
description: Convert a string into an ISO 3166 country code value.
slug: /docs/transforms/operations/iso-3166
tags: ['Transforms', 'Transform Operations']
---

## Overview

Use the ISO3166 transform to convert an incoming string into an [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) country code value. The incoming data must be either a recognized country name or country code:

- The alpha2 country code (e.g. "ES")
- The alpha3 country code (e.g. "ESP)
- The numeric country code (e.g. 724)
- The English name for the country (e.g. Spain)
- The native name for the country (e.g. España)

The output value can be any of these three values:

- Two-character country code (e.g., "US")
- Three-character country code (e.g., "USA")
- Numeric country code (e.g., "840")

:::note Other Considerations

If the input string to the transform does not represent a valid country code or country name, the transform returns null.

:::

## Transform Structure

The transform for iso3166 only requires the transform's `type` and `name` attributes:

```json
{
  "type": "iso3166",
  "name": "ISO3166 Transform"
}
```

## Attributes

- **Required Attributes**

  - **type** - This must always be set to `iso3166`.
  - **name** - This is a required attribute for all transforms. It represents the name of the transform as it will appear in the UI's dropdown menus.

- **Optional Attributes**
  - **requiresPeriodicRefresh** - This `true` or `false` value indicates whether the transform logic should be reevaluated every evening as part of the identity refresh process.
  - **format** - Use this optional value to denote which ISO 3166 format to return. The following values are valid:
    - `alpha2` - Two-character country code (e.g., "US"). This is the default value if you do not provide a format.
    - `alpha3` - Three-character country code (e.g., "USA")
    - `numeric` - The numeric country code (e.g., "840")
  - **input** - This is an optional attribute that can explicitly define the input data passed into the transform logic. If no input is provided, the transform takes its input from the source and attribute combination configured with the UI.

## Examples

Because no specific format is provided, this transform defaults to the alpha2 output and returns "US".

```bash
Input: "United States of America"
Output: "US"
```

**Transform Request Body**:

```json
{
  "type": "iso3166",
  "name": "ISO3166 Transform"
}
```

---

<p>&nbsp;</p>

Because the desired format is specified as numeric, the output of this transform returns "724".

```bash
Input: "ES"
Output: "724"
```

**Transform Request Body**:

```json
{
  "attributes": {
    "format": "numeric"
  },
  "type": "iso3166",
  "name": "ISO3166 Transform"
}
```

## References

- [https://en.wikipedia.org/wiki/ISO_3166](https://en.wikipedia.org/wiki/ISO_3166)
