# Fields - Formatters

Quick examples:

```
{field | toFixed:2} > Sets number decimal precision 5300.1 > 5300.10
{field | format:2:',':'.'} > Sets number decimal precision, thousand separator, decimal separator e.g.  5300.1 > 5,300.00
{field | round:2} > Sets number decisal precision and it rounds value to specific precision e.g. 5300.5783 > 5300.58
{field | roundUp:2} > Sets number decisal precision and it rounds value up to specific precision e.g. 5300.5783 > 5300.58
{field | roundDown:2} > Sets number decisal precision and it rounds value down to specific precision e.g. 5300.5783 > 5300.57
{field | inWords:'en'} > Spells Number in words based on selected language 5300.1 > five thousand three...
{field | date:'de-DE'} > Formats Date in specific format
{field | addDays:7} > Add specified number of days to provided input date
{field | time:'en-US':'America/New_York'} > Formats Time in specific format and timezone
{field | uppercase } > Sets text uppercase e.g. "TEST"
{field | lowercase } > Sets text lowercase e.g. "test"
{field | capitalize } > Capitalize first letter of text e.g. "Test"
{field | extractBefore:'st' } > Extract part of text before match e.g. "Testing" > "Te"
{field | extractAfter:'st' } > Extract part of text after match e.g. "Testing" > "ing"
{field | trim } > Trim whitespace before and after text e.g. "  Test " > "Test"
```

### Special Field formatter “format”

If you want format number that reflect money in some specific world format you can do that using format filter. It will allow you set following parameters:

* decimal points (default: 2)
* thousands delimiter (default: ',')
* decimal delimiter (default: '.')

**\[fieldName] | format:\[decimalPoints]:"\[thousandDelimiter]":"\[decimalDelimiter]"**

```
{field} > 5300.1
{field | format} > 5300.1 > 5,300.10
{field | format:3} > 5300.1 > 5,300.100
{field | format:2:'.':','} > 5300.1 > 5.300,10
{field | format:2:'-':','} > 5300.1 > 5-300,10
{field | format:4:' ':'.'} > 5300.1 > 5 300.1000
```

### Special Field formatter “toFixed”

It’s pretty common that you need to calculate the field and see the output in specific precision (especially if you calculate price/cost in some currency).

E.g. If the result of the calculation are 1.54212 > the output will be converted to 1.54. It's a simplified format function. **If you want to round numbers to specific precision use the "round" filter instead.**

```
{field} > 5300.1
{field | toFixed} > 5300
{field | toFixed:2} > 5300.10
{field | toFixed:3} > 5300.100
{field | toFixed:0} > 5300

{field2} > 499.997
{field2 | toFixed} > 499
{field2 | toFixed:2} > 499.99
```

### Special Field formatter "round", "roundUp", "roundDown"

This filter works in a similar way as "toFixed" however it rounds / rounds up / rounds down value to specific precision

```
{field} > 5300.1
{field | round} > 5300
{field | round:2} > 5300.10
{field | roundUp} > 5301
{field | roundDown} > 5300

{field2} > 499.997
{field2 | round} > 500
{field2 | round:2} > 500.00
{field2 | roundDown:1} > 499.9

{field3} > 5.56789
{field3 | round} > 6
{field3 | round:2} > 5.57
{field3 | roundDown:2} > 5.56
{field3 | roundUp} > 6
{field3 | roundDown} > 5
```

### Special Field formatter “inWords”

It’s quite common that you need your value being spelled in words on your document

```
{field} > 501
{ field | inWords: 'en'} > five hundred and one
{ field | inWords: 'pl'} > pięćset jeden

More Advanced Example:
{price} USD > 149.99 USD
{$ price | format:0 | inWords:'en'} dollars and {$ price % 1 * 100 | format:0 | inWords:'en'} cents > one hundred and forty-nine dollars and ninety-nine cents
```

E.g. If results value is 4500, output will be converted to “four thousand and five hundred”

Let’s apply this to example above to get proper USD values:

By Default inWords is set to English but it support following languages:

```
en (English, default)
ar (Arabic)
cz (Czech)
dk (Danish)
de (German)
es (Spanish)
fr (French)
fa (Farsi)
he (Hebrew)
hu (Hungarian)
id (Indonesian)
it (Italian)
ko (Korean)
lt (Lithuanian)
lv (Latvian)
nl (Dutch)
no (Norwegian)
pl (Polish)
pt (Portuguese)
ru (Russian)
sr (Serbian)
tr (Turkish)
uk (Ukrainian)
zh (Chinese)
```

### Special Field formatter "date"

You can display provided date in format you desire in output document (if Date is provided in format that could be parsed).

It supports three optional parameters:

**{ field | date:'\[format]':'\[input]':'\[style]'}**

**Parameters:**

**format \[optional]** - output date locale format using language code | **Default: 'en-US'**

```
'en-US', 'en-GB', 'en-AU', 'en-CA', 'fr-FR', 'de-DE', 'es-ES', 'es-MX', 'it-IT', 'pl-PL', 'nl-NL', 'pt-BR', 'ja-JP', 'zh-CN', 'hi-IN'....
```

**input \[optional]** - input format of date if provided as a string, recommended to set to prevent confusion (month vs days in first place). | **Default: 'auto' - Detected automatically**&#x20;

* When your date is an string date for example `10/03/2026`, `input` acts input format

```
'YYYY-MM-DD', 'DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD.MM.YYYY', 'MM-DD-YYYY'
```

* When your date is passed as an ISO date (for example `2024-01-05T10:00:00Z`), `input` acts as the desired date output timezone

```
'UTC', 'Europe/London', 'Europe/Berlin', 'America/New_York', 'Asia/Tokyo'....
```

{% hint style="info" %}

* For dates like `05/01/2024`, always set explicit `input` format to avoid confusion.
* For ISO values like `2024-01-05T10:00:00Z`, set `input` to timezone when timezone-specific output matters. (Use valid timezone names - `Europe/Berlin`, `UTC`, etc...)\
  <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>&#x20;
  {% endhint %}

**style \[optional]** - date display style | **Default: Auto selected - depends on "format"**

```
'full', 'long', 'medium', 'short'
```

Examples for date:

```
{field} ---> 4/28/2023
{field | date:'en-US'} ---> 4/28/2023
{field | date:'de-DE'} ---> 28.4.2023
{field | date:'en-GB'} ---> 28/04/2023
{field | date:'fr-FR'} ---> 28/04/2023
{field | date:'es-ES'} ---> 28/4/2023
{field | date:'ja-JP'} ---> 2023/4/28

Style Formats:
{field | date:'en-US':'DD/MM/YYYY':'short'} ---> 4/28/23
{field | date:'en-US':'DD/MM/YYYY':'medium'} ---> Apr 28, 2023
{field | date:'en-US':'DD/MM/YYYY':'full'} ---> Friday, April 28, 2023

Input Formats:
{field2} ---> 03/10/2026
{field2 | date:'en-US':'DD/MM/YYYY':'medium'} ---> Oct 3, 2026
{field2 | date:'en-US':'MM/DD/YYYY':'medium'} ---> Mar 10, 2026

{field2a} ---> 05.01.2024
{field2a | date:'en-US':'DD.MM.YYYY':'medium'} ---> Jan 5, 2024
{field2a | date:'en-US':'MM.DD.YYYY':'medium'} ---> May 1, 2024

{field2b} ---> 31/01/2026
{field2b | date:'en-US':'auto':'medium'} ---> Jan 31, 2026
{field2b | date:'en-US':'DD/MM/YYYY':'medium'} ---> Jan 31, 2026

ISO Date Format:
{field3} ---> 2026-03-10T10:30:00Z 
{field3 | date:'en-US':'UTC'} ---> 3/10/2026
{field3 | date:'en-US':'Pacific/Pago_Pago'} ---> 3/9/2026
{field3 | date:'en-US':'Europe/Berlin'} ---> 3/10/2026
{field3 | date:'en-US':'Asia/Tokyo'} ---> 3/10/2026
{field3 | date:'en-US':'Pacific/Kiritimati'} ---> 3/11/2026
```

{% hint style="info" %}
You can also use **current date** and format it using date formatter. [See more](https://docs.documentero.com/documentation/smart-fields#show-current-time-and-current-date-with-format-and-timezone)
{% endhint %}

### Special Field formatter "addDays"

You can add specific number of days to provided date or currentDate. (e.g. Current Date + 7 days)

It supports two parameters:

**{ field | addDays:\[days] : '\[inputFormat]'}**

**days \[required]** - number of days that should be added to provided date

**inputFormat \[optional]** - input format of date if provided as a string, recommended to set to prevent confusion (month vs days in first place). | **Default: Detected automatically**&#x20;

```
'YYYY-MM-DD', 'DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD.MM.YYYY', 'MM-DD-YYYY'
```

Examples of adding days to input dates:

```

{field} ---> 2025-03-15
{field | addDays:5} --->  2025-03-20

{field} ---> 05/21/2025
{field | addDays:3} --->  05/24/2025

{field} ---> 10/11/2025
{field | addDays:3:'MM/DD/YYYY'} --->  10/14/2025
{field | addDays:3:'DD/MM/YYYY'} --->  13/11/2025

// Use addDays on currentDate
{$currentDate | addDays:3 | date:'en-US'} --->  Adds 3 days to currentDate and use'en-US' format
{$currentDate | addDays:7 | date:'de-DE'} --->  Adds 7 days to currentDate and use'de-DE' format
```

### Special Field formatter "capitalize", "uppercase", "lowercase"

You can use one of "capitalize", "uppercase", and "lowercase" filters if you want to change the formatting of text to uppercase or lowercase. You can make only first letter uppercase using capitalize. Check examples below:

```
{ field }  > teSt

{ field | uppercase } > TEST
{ field | lowercase } > test
{ field | capitalize } > TeSt
```

### Special Field formatter “hide"

You can use "hide" filter if you want to hide field output on regular field. Useful if you need to use field value withing Smart Fields or Smart Sections but you don't want to show actual value in the document

```
{field | hide}
Field will be defined in document structure but nothing will be visible in the document

{#$ field == "Yes"}
This part of document will apear if field equals Yes
{/}
You can use field within Smart Sections

{$ field == "Yes" ? "TextIfYes" : "TextIfNo" }
You can use field within Smart Fields
```

### Special Field formatter “extractBefore", "extractAfter"

Extract part of text before or after provided matching characteres.&#x20;

```
{field} > mail@domain.com
{field | extractBefore:'@' } > mail
{field | extractBefore:'.com' } > mail@domain
{field | extractAfter:'@' } > domain.com
{field | extractAfter:'domain' } > .com
```

### Special Field formatter “trim"

Trim whitespace before and after text

```
{field} >    test 
{field | trim } > test
```

\
\&#xNAN;*Note: Backslash is escape character for matching special characters if you want to extract before or after backslash '\\' use double blackslach as match e.g. `extractAfter:'\\'`*
