Skip to main content
Number formatting helpers display numbers in human-readable formats.

formatNumber

Formats a number with thousands separators and decimal places.
{{formatNumber 1234567.89}}
{{formatNumber 1234567.89 0}}
{{formatNumber 1234567.89 2 "," "."}}
ArgumentTypeDefaultDescription
numbernumberrequiredNumber to format
decimalsnumber2Decimal places
thousandsSepstring”,“Thousands separator
decimalSepstring”.”Decimal separator
Examples:
{{formatNumber 1234567}}
Output: 1,234,567.00
{{formatNumber 1234567 0}}
Output: 1,234,567
{{! European format }}
{{formatNumber 1234567.89 2 "." ","}}
Output: 1.234.567,89

currency

Formats a number as currency with proper symbol and locale.
{{currency 1234.56 "USD"}}
{{currency 1234.56 "EUR" "de-DE"}}
ArgumentTypeDefaultDescription
amountnumberrequiredAmount to format
currencyCodestring”USD”ISO 4217 currency code
localestring”en-US”Locale for formatting
Examples:
{{currency 1234.56 "USD"}}
Output: $1,234.56
{{currency 1234.56 "EUR"}}
Output: €1,234.56
{{currency 1234.56 "GBP"}}
Output: £1,234.56
{{currency 1234.56 "JPY"}}
Output: ¥1,235 (JPY has no decimals)
{{! German locale }}
{{currency 1234.56 "EUR" "de-DE"}}
Output: 1.234,56 €

Supported Currency Codes

Common currency codes include:
CodeCurrencySymbol
USDUS Dollar$
EUREuro
GBPBritish Pound£
JPYJapanese Yen¥
CNYChinese Yuan¥
INRIndian Rupee
CADCanadian DollarC$
AUDAustralian DollarA$
BRLBrazilian RealR$
KRWKorean Won

percentage

Calculates and formats a percentage.
{{percentage 75 100}}
{{percentage 3 4 2}}
ArgumentTypeDefaultDescription
valuenumberrequiredThe part
totalnumber1The whole
decimalsnumber1Decimal places
Examples:
{{percentage 75 100}}
Output: 75.0%
{{percentage 1 3 2}}
Output: 33.33%
{{percentage completed total 0}}
<!-- 45 of 60 → Output: 75% -->

formatBytes

Formats bytes into human-readable file sizes.
{{formatBytes 1024}}
{{formatBytes 1536000 1}}
ArgumentTypeDefaultDescription
bytesnumberrequiredSize in bytes
decimalsnumber2Decimal places
Examples:
{{formatBytes 0}}
Output: 0 Bytes
{{formatBytes 1024}}
Output: 1 KB
{{formatBytes 1536000}}
Output: 1.46 MB
{{formatBytes 1073741824}}
Output: 1 GB
InputOutput
500500 Bytes
10241 KB
10485761 MB
10737418241 GB
10995116277761 TB

ordinal

Adds ordinal suffix to a number (1st, 2nd, 3rd, etc.).
{{ordinal 1}}
{{ordinal 2}}
{{ordinal 3}}
{{ordinal 4}}
Output: 1st, 2nd, 3rd, 4th Examples:
{{ordinal 21}}  <!-- 21st -->
{{ordinal 22}}  <!-- 22nd -->
{{ordinal 23}}  <!-- 23rd -->
{{ordinal 24}}  <!-- 24th -->
{{ordinal 11}}  <!-- 11th -->
{{ordinal 12}}  <!-- 12th -->
{{ordinal 13}}  <!-- 13th -->
Use cases:
<p>{{ordinal position}} place</p>
<!-- Output: 1st place -->

<p>{{ordinal day}} of {{monthName date}}</p>
<!-- Output: 15th of December -->

Practical Examples

Invoice Line Items

<table>
  <thead>
    <tr>
      <th>Item</th>
      <th>Qty</th>
      <th>Unit Price</th>
      <th>Total</th>
    </tr>
  </thead>
  <tbody>
    {{#each items}}
    <tr>
      <td>{{this.name}}</td>
      <td>{{formatNumber this.quantity 0}}</td>
      <td>{{currency this.unitPrice "USD"}}</td>
      <td>{{currency (multiply this.quantity this.unitPrice) "USD"}}</td>
    </tr>
    {{/each}}
  </tbody>
</table>

File Information

<div class="file-info">
  <span class="name">{{filename}}</span>
  <span class="size">{{formatBytes fileSize}}</span>
</div>

Progress Report

<div class="progress-report">
  <h3>Project Status</h3>
  <p>Tasks: {{completed}} of {{total}} ({{percentage completed total 0}})</p>
  <p>Budget: {{currency spent "USD"}} of {{currency budget "USD"}} ({{percentage spent budget 0}})</p>
</div>

Leaderboard

<ol class="leaderboard">
  {{#each players}}
  <li>
    <span class="rank">{{ordinal (add @index 1)}}</span>
    <span class="name">{{this.name}}</span>
    <span class="score">{{formatNumber this.score 0}}</span>
  </li>
  {{/each}}
</ol>

Multi-Currency Invoice

<div class="totals">
  <p>Subtotal: {{currency subtotal currency}}</p>
  <p>Tax: {{currency tax currency}}</p>
  <p class="grand-total">Total: {{currency total currency}}</p>
</div>
<!-- Works with any currency: USD, EUR, GBP, etc. -->