Formatting Numbers: toFixed, roundNum, commaSeparate, numberConvert

Doc Auto Team
Doc Auto Team
  • Updated

This article goes over formatting numbers using the toFixed, commaSeparate, roundNum and numberConvert functions.

Number Formatting Functions



Example Code



Fix a number to specific number of decimal places

${pricePerShare | toFixed:2}

$1 → $1.00


Round a number to specific decimal places

${pricePerShare | roundNum:2}

$15.34928 → $15.35


Separate number with Commas

{numShares | commaSeparate}

10000 → 10,000


Convert integer into text

{numShares | numberConvert}

1000 → one thousand


Convert integer into ordinal text

{123 | numberConvert:'ordinalWords'}

123 → one hundred twenty third


Currently numberConvert will only work for integers. They will not fully convert numbers with decimals into text but will just print the integer part of the number. (e.g. 101.23 → one hundred and one)


You can customize numbers converted to text with numberConvert by stacking text formatting functions. (e.g. {numShares | numberConvert | upper} : 1000 → ONE THOUSAND)
You can learn more about text formatting here: upper, lower, firstCase


Stacking Number Formatting Functions

The order to stack these functions are:

  1. toFixed/roundNum

  2. commaSeparate/numberConvert