Number and currency formatting in automated renders
Prices and counts break when separators, minor units and rounding are guessed. A template contract for locale-safe numbers in rendered images.
A campaign that ships a price card to five markets renders the same template five times. The layout survives; the number often does not. A practical contract for separators, minor units, rounding and symbols inside rendered images.
The price that changes meaning at the border
A price card goes to five markets. The template is approved once: dark layout, product name, a large number, a small currency mark. The row data arrives from the shop system, which exports the field as 1.234,56 because that is how the finance team reads a price. The template slot expects a number, the renderer receives a string, and whatever the parser decides is what a customer sees. In the worst case the card is not obviously broken. It says 1.23.
A wrong price is not a layout bug. It is a refund, a support ticket and a screenshot. Numbers in rendered images fail in three ways that have nothing to do with design: the separator is interpreted by the wrong locale, the currency's minor unit is ignored, and the value is rounded somewhere between export and render. Each failure has a different fix, and all three are cheap when the template owns them instead of the spreadsheet.

Three decisions, not one
| Decision | What it controls | Symptom when it is guessed |
|---|---|---|
| Locale | Separators, digit shapes, symbol position, spacing | 1.234,56 read as 1.23456 |
| Currency | Code, default fraction digits, symbol | Yen printed with cents, or $ on a Canadian price |
| Precision | Rounding mode, minimum and maximum digits | Totals drift, prices lose a cent per row |
The three are independent. A German locale with US dollars is a legitimate combination and renders as 1.234,56 $. Deciding that the language implies the currency is the first mistake; market, language and currency are three separate fields, and a template that localises text usually localises one of them and forgets the others — the same gap that localised template runs hit when they expand headlines but not numbers.
Separators are locale data, not formatting taste
Hand-built formatting usually starts with a helper that swaps . for ,, which works until the batch meets a market with different grouping or a currency without fractions. Browsers and Node expose the same data through Intl.NumberFormat, widely available since September 2017, and the patterns come from Unicode CLDR, the locale repository behind most operating systems and runtimes.
The same amount, 123,456.789, formatted as currency:
| Locale | Output | Grouping | Note |
|---|---|---|---|
de-DE | 123.456,79 € | . | symbol after the number |
en-US | $123,456.79 | , | symbol before |
fr-FR | 123 456,79 € | U+202F | narrow no-break space |
de-CH | CHF 123'456.79 | ' | code instead of a symbol |
en-IN | ₹1,23,456.79 | , | lakh grouping, 2-2-3 |
ja-JP | ¥123,457 | , | no decimals |
ar-EG | ١٢٣٬٤٥٦٫٧٩ ج.م. | ٬ | Arabic-Indic digits, RTL marks |
Two of those characters are invisible in a code review: the French separator is U+202F, not a normal space, and the Arabic output carries U+200F marks around the number. A test that trims or normalises whitespace passes on output a customer cannot read.
Runtime data also lags the standard. CLDR 49 was released on 22 October 2026, while the Node 22 build used for these examples shipped CLDR 48.0. Formatting differences between releases are rare but real, so pin the runtime behind visual snapshots and treat a runtime upgrade as a change to the render contract.
Minor units are not always two
| Currency | Default digits | Rendered in en-US |
|---|---|---|
JPY | 0 | ¥123,457 |
USD | 2 | $123,456.79 |
EUR | 2 | €123,456.79 |
KWD | 3 | KWD 1,234.500 |
CLF | 4 | CLF 1,234.5000 |
Setting minimumFractionDigits: 2 globally, a common "make all prices look consistent" rule, overrides the currency default: the same formatter prints ¥1,234.57 for a yen amount. That is not a unit anyone can pay. If a business rule needs fixed precision, as unit prices sometimes do, apply it per currency and write down why it exists.
Read the number before you format it
Most damage happens before formatting. A CSV cell containing 1.234,56 is ambiguous; 1,234.56 is ambiguous in the other direction; 1 234,56 may carry a non-breaking space that survives the export and breaks the parser silently. Three options, in order of preference:
- Neutral export. Dot decimal, no grouping, no symbol (
1234.56), plus separatecurrencyandlocalecolumns. The row stays a number. - Declared parse. When the export format is fixed, name the decimal and grouping characters per column in the template contract and parse with those, never with the runtime default.
- Pre-formatted string. The upstream system formats and the template only displays. Fast, but the render can no longer validate or re-localise the value.
JsonCut templates take typed inputs, and bulk rows are validated against the published input types before anything queues. A number input that receives a comma string becomes a visible row error instead of a plausible wrong price, which is exactly the behaviour you want from a template input contract. The data hygiene pre-flight covers the rest of the CSV contract; numbers are simply its most expensive corner.
A second, quieter problem is floating point. In the runtime used here, 8.7 * 3 evaluates to 26.099999999999998. Formatted with two digits it still reads 26.10, so the card looks right while the total behind it drifts. Store amounts as integer minor units, add and multiply in that unit, and convert to a decimal number only at the edge where formatting happens.
Options that quietly change the meaning
| Option | Default | What it changes |
|---|---|---|
roundingMode | halfExpand | rounds .5 away from zero; alternatives such as halfEven, ceil or floor belong in a documented rule |
minimumFractionDigits / maximumFractionDigits | from the currency | the only two values that decide how many decimals appear |
trailingZeroDisplay: "stripIfInteger" | auto | prints $1,234 instead of $1,234.00 |
signDisplay: "always" | auto | +$1,234.50 for deltas, so +5 and −5 do not look alike |
currencySign: "accounting" | standard | negative amounts in parentheses: ($1,234.50) |
useGrouping: "min2" | auto | drops the separator below five digits (1234); false removes it entirely (1234567) |
currencyDisplay | symbol | code gives USD 1,234.50, name gives 1,234.50 US dollars |
The defaults are good. The risk is a single global configuration object that sets one of these for every market because it fixed one card in one review.
Symbols are ambiguous; codes are not
| Symbol | Used by | What a reader may assume |
|---|---|---|
$ | USD, CAD, AUD, NZD, SGD, HKD, MXN and more | "our dollars" |
¥ / ¥ | JPY, CNY | yen or yuan |
kr | SEK, NOK, DKK, ISK | krona or krone |
In the same runtime, narrowSymbol renders a US-dollar amount as $1,234.50 for both en-US and en-CA. The formatter is not wrong; it localises the symbol for the locale, it does not disambiguate the currency. Where two currencies are normal, the ISO code belongs in the card, and the currency name belongs in the alt text: currencyDisplay: "name" gives 1,234.50 US dollars, which is what a screen reader needs — the same reasoning that governs alt text in automated image output.
A contract for the price slot
| Field | Type | Rule |
|---|---|---|
amount_minor | integer | value in the currency's minor unit; never a float |
currency | string | ISO 4217 code from an allowlist |
locale | string | BCP 47 tag from an allowlist, such as de-DE or fr-CA |
display | string, optional | symbol, code or name; default symbol |
precision | string, optional | currency-default or a named rule such as unit-price-4 |
Format inside the template, not in the spreadsheet. Keep the formatted string next to the row id in the batch report, so a support request can be answered without re-rendering. And carry the locale per row, not per batch: the batch pins a template version, the row carries the market.
Test the characters you cannot see
A snapshot test per locale is enough when it compares exact strings. Assert the NBSP in 123.456,79 €, the U+202F in the French grouping and the RTL marks in the Arabic output. Then look at one render per locale at final size: a price that wraps between number and symbol reads as two separate elements, and a glyph missing from the font (₹, ¥, ₩) falls back to a different font with a different weight. Fallback is usually acceptable, but it is a visual decision and belongs in the review, not in the log.
Checklist before the next batch
- Amounts stored as integer minor units; currency as ISO code; locale as BCP 47 tag.
- One formatter per row, called with that row's locale and currency. No manual separator replacement.
- No global
minimumFractionDigitsoverride across currencies. - Ambiguous CSV cells rejected instead of reinterpreted.
currencyDisplaychosen per context: symbol in-market, code when mixed, name for assistive text.- Sign and accounting format decided once for deltas and refunds.
- Snapshot strings per locale, including invisible characters.
- One final-size visual check per locale, not just per template.
None of this is exotic. It is the same discipline as typed template inputs and validated rows: put the rule where it can be checked, and let the rendered result show what a customer will actually see.
Sources (retrieved 1 December 2026)
MDN: Intl.NumberFormat — https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
Unicode CLDR project (CLDR 49, 22 October 2026) — https://cldr.unicode.org/
Unicode CLDR 48, Verify Number Formats: German — https://www.unicode.org/cldr/charts/48/verify/numbers/de.html
JsonCut docs: Typed templates and bulk rendering — https://jsoncut.com/docs/templates/