> For the complete documentation index, see [llms.txt](https://documentation.crossengage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.crossengage.io/data-and-engagement-platform/messages/personalization/formatting-functions/number-formatting.md).

# Number Formatting

To format numbers on CrossEngage, you should use the `formatDigits` function. The syntax of this formatting function is:

```jsx
{{formatDigits '{
    "propertyName": [Value that should be formatted], 
    "numberDecimals": [Decimals number],
    "decimalSeparator": [Decimal separator], 
    "thousandsSeparator": [Thousand separator],
    "percentage": [Percentage option]
    }'
}}
```

{% hint style="warning" %}
Please note that the formatDigits helper function only works when used with either the `#includeProducts` or `#findProduct` helper function.
{% endhint %}

| Property             | Type    | Description                                                                                                   |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| `propertyName`       | string  | **Required**. The attribute containing the value that is used for formatting. e.g. `[properties.price]`       |
| `numberDecimals`     | integer | **Required**. The number of decimals that is displayed. e.g. `2`                                              |
| `decimalSeparator`   | string  | **Optional**. The string that is used to separate decimals e.g. `,`                                           |
| `thousandsSeparator` | string  | **Optional**. The string that is used to separate thousands e.g. `.`                                          |
| `percentage`         | boolean | **Optional**. This option specifies whether the value should be formatted as a percentage or not. e.g. `true` |

#### Formatting the price of a product extracted from the product feed

Using the helper function `#findProduct`, we search for a particular `sku` and format the result's  `[properties.price]` attribute. We use `2000` as the value of the product's price for the example below.

```jsx
{{formatDigits '{
    "propertyName": "[properties.price]", 
    "numberDecimals": 2,
    "decimalSeparator": ",", 
    "thousandsSeparator": ".",
    "percentage": "false"
    }'
}}
```

Once the function is evaluated, it displays `2.000,00` in the section where it is used in the message.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.crossengage.io/data-and-engagement-platform/messages/personalization/formatting-functions/number-formatting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
