Skip to main content

Viewer Number Helpers

This page explains common number helpers you can use in Viewer templates.

Use these helpers to format and convert numeric values for cleaner document output.

Function name meaning (quick reference)

  • addCommas = format number with thousands separators
  • toFixed = keep a fixed number of decimal places
  • toInt = convert value to an integer
  • toFloat = convert value to a decimal number
  • toPrecision = format number with significant digits
  • toExponential = show number in exponential notation
  • bytes = format bytes into KB/MB/GB display

addCommas

Formats a number with comma separators.

Scenario: Show revenue in a readable format.

addCommas example: revenue
{{addCommas Opportunity.Amount}}
addCommas with actual number
{{addCommas 1250000}}

Expected result: 1,250,000

toFixed

Formats a number with fixed decimal places.

Scenario: Always show 2 decimals for pricing.

toFixed example: currency style
{{toFixed Opportunity.Total_Price__c 2}}
toFixed with actual number
{{toFixed 19.9 2}}

Expected result: 19.90

toInt

Converts a value to an integer.

Scenario: Remove decimals for rounded quantity display.

toInt example: quantity
{{toInt Opportunity.Estimated_Users__c}}
toInt with actual number
{{toInt 42.88}}

Expected result: 42

toFloat

Converts a value to float (decimal number).

Scenario: Ensure numeric decimal formatting for calculations.

toFloat example: decimal conversion
{{toFloat Opportunity.Unit_Price_Text__c}}
toFloat with actual number
{{toFloat "42.88"}}

Expected result: 42.88

toPrecision

Formats a number using significant digits.

Scenario: Display concise scientific or KPI values.

toPrecision example
{{toPrecision Opportunity.Score__c 4}}
toPrecision with actual number
{{toPrecision 1234.567 4}}

Expected result: 1235

toExponential

Converts a number to exponential notation.

Scenario: Show very large values in compact technical format.

toExponential example
{{toExponential Opportunity.Large_Number__c 2}}
toExponential with actual number
{{toExponential 1250000 2}}

Expected result: 1.25e+6

bytes

Formats byte values into readable units.

Scenario: Show file size in KB/MB instead of raw bytes.

bytes example: file size
{{bytes ContentVersion.ContentSize}}
bytes with actual number
{{bytes 1048576}}

Expected result: 1 MB

Practical end-to-end example

Invoice summary with number helpers
Invoice amount: {{addCommas Opportunity.Amount}}
Tax rate: {{toFixed Opportunity.Tax_Rate__c 2}}%
Tax amount: {{addCommas (toFixed Opportunity.Tax_Amount__c 2)}}
Grand total: {{addCommas (toFixed Opportunity.Grand_Total__c 2)}}
Attachment size: {{bytes ContentVersion.ContentSize}}

Number helper tips

  • Use addCommas for user-facing amounts.
  • Use toFixed for currency-like values.
  • Use toInt and toFloat when field types are inconsistent.
  • Keep output format consistent across the same document.

Common Use Cases

How do I add comma separators to large numbers?

Use addCommas for readability:

Total Revenue: {{addCommas Opportunity.Amount}}

Result: 1,250,000 instead of 1250000

How do I format prices with exactly 2 decimal places?

Use toFixed for currency:

Price: {{toFixed Product2.Price 2}}

Result: 19.99 (or 19.00 if value is 19)

How do I remove decimal places from a quantity?

Use toInt for whole numbers:

Estimated Users: {{toInt Opportunity.Estimated_Users__c}}

Result: 42 (from 42.88)

How do I handle fields that might be text instead of numbers?

Use toFloat to convert text to numbers:

{{toFloat Opportunity.Unit_Price_Text__c}}

Result: 42.88 (converts "42.88" string to number)

How do I format very large numbers compactly?

Use toExponential for scientific notation:

Large Value: {{toExponential 1250000 2}}

Result: 1.25e+6

How do I show file sizes in human-readable format?

Use bytes to format KB/MB:

File Size: {{bytes ContentVersion.ContentSize}}

Result: 2.5 MB (from 2621440 bytes)

More resources