---
schema_version: "1"
id: f8ea3c4a44d7daefdefb60064f6f97ceea2c887eddbc543ec61fc40b7fbb93ad
title: FormatNumber()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/utilities/mc-ampscript-reference-utilities-formatNumber.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-utilities/mc-ampscript-reference-utilities-formatNumber.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9724327583e625fe934fabce201777c5f088e8ab174b9d55cc8abc857d3681ac
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# FormatNumber()

Formats a number as a numeric type, such as a decimal, date, or currency value.

You can also use this function to convert numbers stored in strings to a number data type, and to round numbers to a certain number of decimal places.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

## Syntax

```
FormatNumber(number, formatType, cultureCode)
```

The `FormatNumber()` function has three parameters:

- `number` (string or number): Required. The number that you want to format. This function assumes that the input number uses a period (.) as a decimal separator.
- `formatType` (string): Required. The number type to convert the number to. Accepted values:

  - C - Formats the number as a currency value.
  - D - Formats the number as a decimal number.
  - E - Formats the number using scientific notation.
  - F - Formats the number to a fixed number of decimal places (two decimal places by default).
  - G - Formats the number without thousands separators.
  - N - Formats the number with thousands separators.
  - P - Formats the number as a percentage.
  - R - Round-trip (format ensures value parsed to string can be parsed back to numeric value)
  - X - Formats the number as a hexadecimal value.

  You can optionally follow this code with a number to indicate the precision of the number. For example, a currency value with two decimal places uses the parameter C2.

- `cultureCode` (string): A POSIX locale code, such as `en_US` or `zh-TW`. When you provide this value, the resulting number is formatted using patterns that suit the specified locale.

## Usage

To use the function, pass it a number to format, and the numeric type that you want to convert it to. You can optionally include a POSIX locale code. If you do, the function returns the resulting number in a format that aligns with the formatting practices of the specified culture.

The following sections show several of the ways that you can use this function to format numbers.

### Rounding

This example uses the N (number) type. The N is followed by a 2, indicating that the resulting number is rounded to two decimal places.

```
%%=FormatNumber(123.445,"N2")=%%
```

The function returns `123.45`.

### Converting Strings to Numbers

This example converts a string to a number data type.

```
%%=FormatNumber("1234.56", "N")=%%
```

The function returns `1,234.56`.

### Normalizing Numbers

You can use the G (general) number type to remove the thousands separators from numbers that are passed as strings.

```
%%=FormatNumber("1,234.56","G","en_US")=%%
```

The function returns `1234.56`.

### Localizing Numbers

This example formats the input number as a currency value, rounded to two decimal places. It also formats the resulting number using rules that align with the `de_DE` (Germany) locale.

```
%%=FormatNumber("123.445","C2","de_DE")=%%
```

The function returns `123,45 €`.

### Converting Numbers to Percentages

This example converts the result of dividing two numbers into a percentage.

```
%%[
  Set @val1 = 42
  Set @val2 = 326
  Set @pct = Divide(@val1, @val2)
]%%

%%=FormatNumber(@pct, "P3")=%%
```

The function returns `12.883%`.
