--- title: "Numbers" slug: "numbers-filter" updated: 2026-02-25T17:38:12Z published: 2026-02-25T17:38:12Z canonical: "learn.servitly.com/numbers-filter" --- > ## Documentation Index > Fetch the complete documentation index at: https://learn.servitly.com/llms.txt > Use this file to discover all available pages before exploring further. # Numbers Transform and displays numeric values in different ways and formats. ![Numbers](https://components-manager.servitly.com/components/Numbers_1/IMAGES/_screenshot?owner=AG_Servitly) This filter and its variants can be applied to *metrics* and *properties* of numeric type, or strings holding a numeric value. Depending on the variant options, the underlying value is parsed as number and then formatted. # Filter Variants The set of predefined filter variants that can be used to format values. | **Bytes** | | --- | | *Bytes to KBytes (##.#)* | Formats the given number converting from bytes to Kbytes. **Name**: *bytesToKBytes* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `1024 -> 1` `null or empty -> 0` | | *Bytes to MBytes (##.#)* | Formats the given number converting from bytes to Mbytes. **Name**: *bytesToMBytes* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `1048576 -> 1` `null or empty -> 0` | | **Number** | | *###* | Formats the number value as an integer without decimal digits, if null prints an empty string. **Name**: *integerFormat* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *INTEGER* `5.1234 -> 5` `null or empty -> null` | | *### or N/A* | Formats the number value as an integer without decimal digits, if null prints the default null value or "-". **Name**: *integerFormatDefault* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `5.1234 -> 5` `null or empty -> N/A` | | *###.#* | Formats the number value as a float with 1 decimal digit, if null prints an empty string. **Name**: *singleDecimalFormat* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `5.1234 -> 5.1` `null or empty -> null` | | *###.# or N/A* | Formats the number value as a float with 1 decimal digit, if null prints the default null value or "-". **Name**: *singleDecimalFormatDefault* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `0.1234 -> 0.1` `null or empty -> N/A` | | *###.##* | Formats the number value as a float with 2 decimal digits, if null prints an empty string. **Name**: *twoDecimalFormat* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `5.1234 -> 5.12` `null or empty -> null` | | *###.## or N/A* | Formats the number value as an integer with 2 decimal digits, if null prints the default null value or "-". **Name**: *twoDecimalFormatDefault* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `0.1234 -> 0.12` `null or empty -> N/A` | | *###.###* | Formats the number value as an integer with 3 decimal digits, if null prints the default null value or "-". **Name**: *threeDecimalFormatDefault* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `0.1234 -> 0.123` `null or empty -> -` | | *##0.0 or 0.0* | Formats the number value as a float with 1 decimal digit, if null prints 0. **Name**: *singleDecimalFormatZero* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `0.1234 -> 0.1` `null or empty -> 0.0` | | *##0.00* | Formats the number value as an integer with 2 decimal digits, if null prints 0. **Name**: *twoDecimalFormatZero* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `0.1234 -> 0.12` `null or empty -> 0.00` | | *#,###.###* | Formats a number in the localized format using decimal and thousand separators. The number of decimal places depends on the value: 0 decimal places if greater than 1000, 1 decimal place if greater than 100, 2 decimal places if greater than 10, 3 decimal places if less than 10. **Name**: *numberFormat* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `10345 -> 10,345` `10.456 -> 10,5` `null or empty -> null` | | **Percentage** | | *Float to Percentage (## %)* | Formats the given float number (0 to 1) as a percentage (0 to 100) with % sign. **Name**: *floatToPercentageWithUnit* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `0.45 -> 45 %` `null or empty -> 0 %` | | *Float to Percentage (##)* | Formats the given float number (0 to 1) as a percentage (0 to 100). **Name**: *floatToPercentage* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `0.45 -> 45` `null or empty -> 0` | | **Pressure** | | *Bar to psi (##.# psi)* | Formats the given float number converting from bar to psi adding the unit of measurement (psi). **Name**: *barToPSIWithUnit* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `1 -> 14.5038 psi` `null or empty -> 0 psi` | | *Bar to psi (##.#)* | Formats the given float number converting from bar as PSI. **Name**: *barToPSI* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `1 -> 14.5038` `null or empty -> 0` | | **Temperature** | | *Celsius to Fahrenheit (##.# F)* | Formats the given float number converting from celsius to Fahrenheit adding the unit of measurement (F). **Name**: *celsiusToFahrenheitWithUnit* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `25 -> 77 F` `null or empty -> 0 F` | | *Celsius to Fahrenheit (##.#)* | Formats the given float number converting from celsius to Fahrenheit. **Name**: *celsiusToFahrenheit* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `25.0 -> 77.0` `null or empty -> 0` | | **Volume** | | *Liters to Gallons (##.# gal)* | Formats the given float number converting from liters to Gallons adding the unit of measurement (gal). **Name**: *literToGallonWithUnit* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *STRING* `1 -> 0.264172 gal` `null or empty -> 0 gal` | | *Liters to Gallons (##.#)* | Formats the given float number converting from liters to Gallons. **Name**: *literToGallon* **Input Types**: *INTEGER, FLOAT, NUMBER* **Output Type**: *FLOAT* `1 -> 0.264172` `null or empty -> 0` | # Custom Variants New variants can be defined through the following configuration options. | **Option** | **Description** | **Sample Value** | | --- | --- | --- | | *conversionFormula* | The formula which can be used to convert values (optional). | value * 9/5 + 32 | | *defaultNullValue* | The flag that indicates whether to use the default null value in case the input value is null or empty. | true | | *localize* | If true, the number is formatted according to the page locale (default false). Note that, according to the locale, the result number may be a simple string (e.g. *10,5* for it-IT). | | | *nullValue* | The null value to print if the input value is null or empty. | - | | *minPrecision* | The minimum number of decimal places to print (default 0). eg. by setting 2, the number *10* is printed as *10.00* | 1 | | *precision* | The number of decimal places to print. If not specified, no truncation is done. | 2 | | *scale* | The multiplier applied to the input value before it is printed. (default 1) | 100 | | *unit* | The optional unit of measurement to display aside the value. (default null) | Kg | | *useGrouping* | If true and *localize=true*, the number is formatted by using the thousand separator (default false). | true | Example of defining a custom number filter variants into the [Custom Filters](/docs/custom-filters) component. ```javascript        exports.euros= NumberFormatter({ "precision": 2, "nullValue": "-", "localize": true, "useGrouping": true, "unit" : "€" });        exports.kilosToTons = NumberFormatter({ "precision": 1, "nullValue": 0, "conversionFormula": "value / 1000" });     ```