formatNumber

The formatNumber() function formats a number as a string with additional stylistic formatting, such as commas or currency formatting.

Use it to display a number with commas at each thousands-place, add a dollar sign, display a number with “humanized” formatting (e.g. 12M instead of 12,000,000), etc – without needing to use complex regular expressions. This function is especially useful in formulas where you need to display a number alongside additional text.

formatNumber(number, format?, precision?)
number.formatNumber(format?, precision?)

/* "?" denotes an optional argument */
Code language: JavaScript (javascript)

Heads up: formatNumber() returns a string, meaning you can’t do math on its output . In Table views, the Calculate function also won’t offer arithmetic options.

formatNumber() accepts two optional arguments:

  1. Format – the format/style to be used for the formatted number. See the available options in the table below.
  2. Precision – the number of decimal places (0-12) to display in the final, formatted number. Adds as many 0 characters to numbers without decimals.

Here are all the available format options, with an example for each. Note that formatNumber() defaults to “commas” if you don’t pass any arguments.

Format OptionExample InputExample Output
commas1234512,345
percent0.85685.6%
humanize or compact12345671.2M
bytes_decimal1234567812.35 MB
bytes_binary or bytes1234567812.06 KiB
usd or dollar1234.56$1,234.56
aud1234.56A$1,234.56
cad1234.56CA$1,234.56
sgd1234.56SGD 1,234.56
eur or euro1234.56€1,234.56
gbp1234.56£1,234.56
jpy or yen1234.56¥1,235
rub1234.56RUB 1,234.56
inr1234.56₹1,234.56
krw1234.56₩1,235
cny1234.56CN¥1,234.56
brl1234.56R$1,234.56
try1234.56TRY 1,234.56
idr1234.56IDR 1,234.56
chf1234.56CHF 1,234.56
hkd1234.56HK$1,234.56
nzd1234.56NZ$1,234.56
sek1234.56SEK 1,234.56
nok1234.56NOK 1,234.56
mxn1234.56MX$1,234.56
zar1234.56ZAR 1,234.56
twd1234.56NT$1,234.56
dkk1234.56DKK 1,234.56
pln1234.56PLN 1,234.56
thb1234.56THB 1,234.56
huf1234.56HUF 1,234.56
czk1234.56CZK 1,234.56
ils1234.56₪1,234.56
clp1234.56CLP 1,235
php1234.56₱1,234.56
aed1234.56AED 1,234.56
cop1234.56COP 1,234.56
sar1234.56SAR 1,234.56
myr1234.56MYR 1,234.56
ron1234.56RON 1,234.56
ars1234.56ARS 1,234.56
uyu1234.56UYU 1,234.56
pen1234.56PEN 1,234.56

A couple of additional notes on these formats:

  1. humanize will ignore any precision argument provided.
  2. The bytes choices do respect a precision value, but ignore significant decimal places. For example, formatNumber(1.2345, "bytes_decimal", 4) will display 1.2345 B, but formatNumber(1, "bytes_decimal", 4) will display 1 B, not 1.0000 B.
1234.formatNumber() /* Output: 1,234 */

12345.formatNumber("commas", 2) /* Output: 12,345.00 */

1234567.formatNumber("humanize") /* Output: 1.2M */

"Revenue this quarter is " + prop("Revenue").formatNumber("usd")
/* Output: Revenue this quarter is $11,581,619.18 */
Code language: JavaScript (javascript)

You can find a database containing examples of every formatting option at this Notion page:

Notion
A tool that connects everyday work into one space. It gives you and your teams AI tools—search, writing, note-taking—inside an all-in-one, flexible workspace.
thomasfrank.notion.site
About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas