Format Decimal and Grouping Separators in Angular

How Angular's number pipe and formatNumber choose decimal and grouping separators by locale, what the output changes, and when plain unformatted numbers are the safer choice.

Angular formats numbers for display through the DecimalPipe (used in templates as the number pipe) and the formatNumber function, both from @angular/common. Both choose the decimal mark and the thousands separator from locale data rather than from your template, so the same value can appear as 1,234.5 for one audience and 1.234,5 for another. This review explains what that formatting changes, when it suits your use, and where it causes trouble after the text is copied, shared or parsed. No test results or product measurements were supplied for this article, so behavior described here comes from Angular's documented API and the shared locale data it uses. Where a claim depends on a specific browser, screen reader or destination, that is flagged as a gap you should test yourself.

Is locale-aware number formatting suitable for your use?

For numbers that people read on screen, yes. The main benefit is that readers see separators they already understand, which prevents misreading a value like 1.250 as one and a quarter when it was meant as one thousand two hundred fifty, or the reverse. The decisive tradeoff is that the output is a display string, not a number. Once formatted, it is locale-specific, and Angular does not provide a matching parser to turn it back into a number.

Plain, unformatted values are preferable wherever a machine or another program reads the text: form values sent to a server, API payloads, CSV or spreadsheet exports, query strings, logs, and anything stored in a database. In those places, keep the raw number, or use one fixed format (typically a period as the decimal mark and no grouping) that every consumer agrees on.

What the formatting actually changes

This is a character-level formatting step, not a visual effect. It does not reverse text, mirror glyphs, swap in decorative Unicode letters, or apply CSS. The pipe takes a numeric value and produces a new string whose characters, including the separators, are chosen by the locale. The number in your component stays unchanged. Only the rendered text differs.

Angular reads separators from locale data generated from the Unicode CLDR project. That data defines the decimal symbol, the grouping symbol and the grouping pattern for each locale. As a result, the separator is not always a plain comma or period, and groups are not always three digits.

  • English (United States), Angular's default locale: comma for grouping, period for decimals, as in 1,234,567.891.
  • German: period for grouping, comma for decimals, as in 1.234.567,891.
  • French: a non-breaking space character for grouping and a comma for decimals. Current CLDR data uses a narrow no-break space (U+202F) for this. Older data used a regular no-break space (U+00A0), so the exact character depends on the CLDR version bundled with your Angular release.
  • Swiss German: an apostrophe-style character for grouping.
  • Indian English: a secondary grouping pattern, as in 12,34,567, rather than uniform groups of three.

These examples reflect the published locale conventions, not a test run for this article. Check the actual output of your Angular version before relying on a specific character, especially for French and other locales that use space-like separators.

Setting the locale

Without configuration, Angular formats numbers as en-US. To use another locale application-wide, register its data and provide LOCALE_ID. If your project uses Angular's built-in i18n build with a configured locale, the CLI can set this for you. The manual setup looks like this:

import { ApplicationConfig, LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';

registerLocaleData(localeDe);

export const appConfig: ApplicationConfig = {
  providers: [{ provide: LOCALE_ID, useValue: 'de' }]
};

The pipe also accepts a locale as its last argument, which overrides LOCALE_ID for that one expression. Any locale you pass must also be registered, or Angular throws a missing-locale-data error at runtime.

<!-- value = 1234567.891 -->
{{ value | number }}               <!-- LOCALE_ID, default digits '1.0-3' -->
{{ value | number:'1.2-2' }}       <!-- exactly two fraction digits -->
{{ value | number:'1.0-0':'fr' }}  <!-- French separators, no fraction -->

The digitsInfo string has the form minIntegerDigits.minFractionDigits-maxFractionDigits. It controls how many digits appear and where rounding occurs. It does not control which separator characters are used. Those always come from the locale.

Outside templates, for example in a service or when building a label in code, formatNumber applies the same rules:

import { formatNumber } from '@angular/common';

const label = formatNumber(1234.5, 'de', '1.2-2'); // expected: '1.234,50'

Changing or removing the comma

A common request is to drop the thousands comma, or to show a comma as the decimal mark. To use a comma decimal, choose a locale that defines one, such as de or fr. The pipe cannot mix separators from different locales.

Angular's DecimalPipe has no option to turn grouping off. When you need a localized decimal mark without thousands separators, one option is the browser's Intl.NumberFormat with useGrouping set to false, wrapped in a small custom pipe if it is used in templates:

new Intl.NumberFormat('de', {
  useGrouping: false,
  minimumFractionDigits: 2,
  maximumFractionDigits: 2
}).format(1234.5); // expected: '1234,50'

Post-processing the pipe's output with string replacement also works, but it is fragile. The separator characters vary by locale and can be invisible space characters, so a replace that targets a regular comma or space will silently miss them.

Will formatted numbers stay usable after copying or sharing?

The formatted string copies as ordinary text, with exactly the characters the locale produced. That is fine for a person reading it, but it causes problems when another program reads it.

  • Parsing back: Angular ships no locale-aware number parser. Calling Number() or parseFloat() on '1.234,50' does not return 1234.5, and on '1,234' parseFloat stops at the comma. If users paste or type localized numbers, you need your own parsing logic tied to the same locale.
  • Invisible separators: in locales that group with no-break or narrow no-break spaces, copied values contain characters that look like spaces but are not. Search, string comparison, spreadsheet import and validation rules written for ordinary spaces may fail to match them.
  • Ambiguity across audiences: a value like 1.234 means different things in en-US and de. Sharing formatted numbers with people or systems in another locale risks misreading unless the locale is clear from context.
  • Editing: showing a formatted string inside an editable input mixes display formatting with the stored value. A common pattern is to show the raw number while the field has focus and the formatted version only for display, though this behavior is something you build yourself, not something the pipe provides.
  • Directional characters: some locales, notably right-to-left ones, define number symbols that may include invisible directional marks. Text copied from these contexts can carry those marks into other systems. Test the specific locales you support.

For accessibility, the formatted text is what screen readers receive. Setting the page or element lang attribute to match the formatting locale gives assistive technology the context it needs to interpret separators. How a particular screen reader voices a given separator, especially narrow no-break spaces or apostrophe-style grouping marks, was not tested for this article and varies by product and voice settings. Verify it with the assistive technology your users rely on rather than assuming that one correct-looking rendering behaves the same everywhere.

When to provide a plain-text equivalent

Keep an unformatted value alongside the display string whenever the number leaves the screen. That means downloads and exports, clipboard actions meant for spreadsheets, values posted to a backend, and data attributes or hidden fields that scripts read. In the template, render the formatted string for people. Everywhere else, pass the raw number or a fixed machine format.

Bottom line

Angular's number pipe and formatNumber are a sound choice for showing numbers with the separators readers expect, as long as the locale is registered and set deliberately. They change the characters of the displayed text, not the underlying value, and they offer no grouping toggle and no reverse parsing. Use them for display only, reach for Intl.NumberFormat when you need control the pipe lacks, and keep plain numbers for anything copied into, exported to or read by another system. The remaining gaps are environment-specific: the exact separator characters in your Angular version, how your target spreadsheets and search tools handle them, and how your users' screen readers voice them. Those need a scoped test before you rely on them.