> For the complete documentation index, see [llms.txt](https://docs.documint.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.documint.me/templates/working-with-dynamic-data/legacy-formatting/number.md).

# Number

To format numbers, use the `$number` format function:&#x20;

{% embed url="<https://www.youtube.com/watch?v=WBOvxcoUSMY>" %}

![](/files/kpYQ4mjR89u3XRVfXXEx)

**Variable Name:** the name of your variable that will contain the value to be formatted.\
**Format String:** the text code that tells Documint how to would like to format the value

#### General

### $number <a href="#var" id="var"></a>

Used for applying custom formatting to numbers.

#### Signature

`{{$number value format_string [locale]}}`

#### Arguments

<table><thead><tr><th width="150">Name</th><th width="235.5333333333333">Description</th><th width="150">Type<select multiple><option value="b0403385da1b4af9a8a894cb7cfa1e88" label="String" color="blue"></option><option value="6a3ca9c830be4cd5a2bcf10d17c44f82" label="Number" color="blue"></option><option value="011b91dfe58a400894b04549ec4f9e02" label="Boolean" color="blue"></option><option value="3c1342f6b38a46e39064bd88015df50d" label="Any" color="blue"></option></select></th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>value</td><td>Name of variable to be formatted</td><td><span data-option="6a3ca9c830be4cd5a2bcf10d17c44f82">Number</span></td><td>true</td></tr><tr><td>format_string</td><td>Pattern for formatting variable. <a href="#standard">See guide below</a></td><td><span data-option="b0403385da1b4af9a8a894cb7cfa1e88">String</span></td><td>true</td></tr><tr><td>locale</td><td>Specify which locale to use for formatting currencies. <a href="#currency">See list below</a></td><td><span data-option="b0403385da1b4af9a8a894cb7cfa1e88">String</span></td><td>false</td></tr><tr><td>default=</td><td>Default value to display when value is blank. Default=''</td><td><span data-option="b0403385da1b4af9a8a894cb7cfa1e88">String, </span><span data-option="6a3ca9c830be4cd5a2bcf10d17c44f82">Number</span></td><td>false</td></tr></tbody></table>

#### Returns

Formatted number

#### **Example #1 - Basic**

```
// given qty_sold is 1250
{{$number qty_sold "0,0"}} // 1,250
```

#### Example #2 - With Default

```javascript
// given qty_sold is blank
{{$number qty_sold "0,0" default="0"}} // 0
```

### Standard

| Value    | Format String | Result |
| -------- | ------------- | ------ |
| <p>10000 |               |        |

</p><p></p><p></p> | "0,0.0000"     | 10,000.0000   |
| 10000.23                      | "0,0"          | 10,000        |
| 10000.23                      | "+0,0"         | +10,000       |
| -10000                        | "0,0.0"        | -10,000.0     |
| 10000.1234                    | '0.000'        | 10000.123     |
| 100.1234                      | "00000"        | 00100         |
| 1000.1234                     | "000000,0"     | 001,000       |
| 10                            | "000.00"       | 010.00        |
| 10000.1234                    | "0\[.]00000"   | 10000.12340   |
| -10000                        | "(0,0.0000)"   | (10,000.0000) |
| -0.23                         | ".00"          | -.23          |
| -0.23                         | "(.00)"        | (.23)         |
| 0.23                          | "0.00000"      | 0.23000       |
| 0.23                          | "0.0\[0000]"   | 0.23          |
| 1230974                       | "0.0a"         | 1.2m          |
| 1460                          | "0 a"          | 1 k           |
| -104000                       | "0a"           | -104k         |
| 1                             | "0o"           | 1st           |
| 100	                          | "0o"           | 100th         |

### Currency

{% tabs %}
{% tab title="Formats" %}
**Example:**

```javascript
// given grand_total is 1800
{{$number grand_total "$0,0.00"}} // $1,800.00
```

| Number       | Format String | String     |
| ------------ | ------------- | ---------- |
| 1000.234     | '$0,0.00'     | $1,000.23  |
| 1000.2       | '0,0\[.]00 $' | 1,000.20 $ |
| 1001         | '$ 0,0\[.]00' | $ 1,001    |
| -1000.234    | '($0,0)'      | ($1,000)   |
| -1000.234    | '$0.00'       | -$1000.23  |
| 1230974      | '($ 0.00 a)'  | $ 1.23 m   |
| {% endtab %} |               |            |

{% tab title="Locales" %}
You can set the locale using the locale code as the third argument.

#### Example

```javascript
// grand_total = 15000
{{$number grand_total "$0,0.00" "en-gb"}} 
// Result: £15,000.00
```

#### Reference

| Name                   | **Code**   |          Example |
| ---------------------- | ---------- | ---------------: |
| United States          | \[default] |        $1,000.00 |
| Bulgarian              | bg         |       лв1 000,00 |
| Chinese (Simplified)   | chs        |        ¥1,000.00 |
| Czech                  | cs         |       Kč1 000,00 |
| Danish (Denmark)       | da-dk      | DKK1.000,00&#xD; |
| German (Switzerland)   | de-ch      |      CHF1 000,00 |
| German                 | de         |        €1 000,00 |
| English (Australia)    | en-au      |        $1,000.00 |
| English (UK)           | en-gb      |        £1,000.00 |
| English (South Africa) | en-za      |        R1 000,00 |
| Spanish (Spain)        | es-es      |        €1.000,00 |
| Spanish                | es         |        $1.000,00 |
| Estonian               | et         |        €1 000,00 |
| Finnish                | fi         |        €1 000,00 |
| French (Canada)        | fr-ca      |        $1 000,00 |
| French (Switzerland)   | fr-ch      |      CHF1'000.00 |
| French                 | fr         |        €1 000,00 |
| Hungarian              | hu         |       Ft1 000,00 |
| Italian                | it         |        €1.000,00 |
| Japanese               | ja         |        ¥1,000.00 |
| Latvian                | lv         |        €1 000,00 |
| Dutch (Belgium)        | nl-be      |       € 1 000,00 |
| Dutch (Netherlands)    | nl-nl      |       € 1.000,00 |
| Norwegian              | no         |       kr1 000,00 |
| Polish                 | pl         |      PLN1 000,00 |
| Portuguese (Brazil)    | pt-br      |       R$1.000,00 |
| Portuguese             | pt-pt      |        €1 000,00 |
| Russian (Ukraine)      | ru-ua      |        ₴1 000,00 |
| Russian                | ru         |     руб.1 000,00 |
| Slovak                 | sk         |        €1 000,00 |
| Slovenian              | sl         |        €1.000,00 |
| Thai                   | th         |        ฿1,000.00 |
| Turkish                | tr         |        ₺1.000,00 |
| Ukrainian (Ukraine)    | uk-ua      |        ₴1 000,00 |
| Vietnam                | vi         |        ₫1.000,00 |

{% endtab %}

{% tab title="Custom Locale" %}
Create custom locales using the following syntax:

#### Example

```javascript
// grand_total = 15000
{{$number grand_total "0,0.0$" s="$U" t="," d="." }}
// Result: 15,000.00$U
```

#### Reference

| Name                       | Code | Default Value |
| -------------------------- | :--: | :-----------: |
| Currency **S**ymbol        |  `s` |      `$`      |
| **T**housands Separator    |  `t` |      `,`      |
| **D**ecimal                |  `d` |      `.`      |
| **Th**ousands Abbreviation | `th` |      `k`      |
| **Mi**llions Abbreviation  | `mi` |      `m`      |
| **Bi**llions Abbreviation  | `bi` |      `b`      |
| **Tr**illions Abbreviation | `tr` |      `t`      |
| {% endtab %}               |      |               |
| {% endtabs %}              |      |               |

### Percentage

| Number      | Format String | String   |
| ----------- | ------------- | -------- |
| 1           | '0%'          | 100%     |
| 0.974878234 | '0.000%'      | 97.488%  |
| -0.43       | '0 %'         | -43 %    |
| 0.43        | '(0.000 %)'   | 43.000 % |

### Duration

| Number | Format String | String   |
| ------ | ------------- | -------- |
| 25     | '00:00:00'    | 0:00:25  |
| 238    | '00:00:00'    | 0:03:58  |
| 63846  | '00:00:00'    | 17:44:06 |

Source:[ numeral.js](http://numeraljs.com/)


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.documint.me/templates/working-with-dynamic-data/legacy-formatting/number.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
