# messageformat

> Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill

Latest version **4.0.0** (published 2025-11-25) · Apache-2.0 license · 329.7K weekly downloads

## Install

```sh
npm install messageformat
pnpm add messageformat
yarn add messageformat
bun add messageformat
```

## Health

**Score 70/100 (B)** — status: stable.

Positive: moderate downloads; has types; esm support; no vulnerabilities.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-11-25 |
| First published | 2012-02-28 |
| Weekly downloads | 329.7K |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^20.19 \|\| ^22.12 \|\| >=24 |
| Dependencies | 0 |
| Unpacked size | 168 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1770 |
| Maintainers | slexaxton, eemeli |
| Keywords | messageformat, unicode, polyfill, internationalization, i18n, localization, l10n |

## Links

- npm: https://www.npmjs.com/package/messageformat
- Repository: https://github.com/messageformat/messageformat
- Homepage: http://messageformat.github.io/messageformat/
- Issues: https://github.com/messageformat/messageformat/issues
- npm.io page: https://npm.io/package/messageformat

## Alternatives

- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads
- [@vendure/ngx-translate-extract](https://npm.io/package/@vendure/ngx-translate-extract.md) — 48.4K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-11-25
- 4.0.0-13 — 2025-09-04
- 4.0.0-12 — 2025-05-14
- 4.0.0-11 — 2025-05-07
- 4.0.0-10 — 2025-03-24
- 4.0.0-9 — 2024-11-21
- 4.0.0-8 — 2024-10-02
- 4.0.0-7 — 2024-02-28
- 4.0.0-6 — 2024-01-07
- 4.0.0-5 — 2023-11-14
- 4.0.0-4 — 2023-06-08
- 4.0.0-3.cf — 2023-03-14
- 4.0.0-3 — 2023-03-14
- 4.0.0-2 — 2022-12-08
- 4.0.0-1 — 2022-10-21
- … 43 more at https://npm.io/package/messageformat/versions

## README

This library provides a formatter and other tools for [Unicode MessageFormat 2.0] (MF2),
the new standard for localization developed by the [MessageFormat Working Group].

This includes a formatter that can be used as a polyfill for
the proposed [ECMA-402 Intl.MessageFormat] formatter.

The API provided by this library is current as of the [LDML 48] (October 2025)
version of the MF2 specification.

[unicode messageformat 2.0]: https://unicode.org/reports/tr35/tr35-messageFormat.html
[messageformat working group]: https://github.com/unicode-org/message-format-wg
[ecma-402 intl.messageformat ]: https://github.com/tc39/proposal-intl-messageformat/
[ldml 48]: https://www.unicode.org/reports/tr35/tr35-76/tr35-messageFormat.html

```sh
npm install --save messageformat
```

```js
import { MessageFormat } from 'messageformat';
import { DraftFunctions } from 'messageformat/functions';

const msg = 'Today is {$today :datetime dateStyle=medium}';
const mf = new MessageFormat('en', msg, { functions: DraftFunctions });

mf.format({ today: new Date('2022-02-02') });
// 'Today is Feb 2, 2022'
```

The library also provides a number of other tools and utilities for MF2, such as:

- MF2 data model conversion tools

  ```js
  import { parseMessage, stringifyMessage } from 'messageformat';
  ```

- MF2 data model validation and transformation tools

  ```js
  import { validate, visit } from 'messageformat';
  ```

- Concreate Syntax Tree (CST) tools for MF2

  ```js
  import { parseCST, messageFromCST, stringifyCST } from 'messageformat/cst';
  ```

- Utilities for building custom function handlers for MF2

  ```js
  import {
    DraftFunctions,
    asPositiveInteger,
    asString
  } from 'messageformat/functions';
  ```

In addition to supporting MF2 syntax,
compilers and formatting function runtimes are also provided for
ICU MessageFormat and Fluent messages:

- [@messageformat/icu-messageformat-1](https://www.npmjs.com/package/@messageformat/icu-messageformat-1)
- [@messageformat/fluent](https://www.npmjs.com/package/@messageformat/fluent)

For more information on the types and functions provided by this package,
see the [documentation site](https://messageformat.github.io/).

> [!IMPORTANT]
> The v4 release of the `messageformat` package has
> an entirely different API compared to its earlier major releases,
> which were built on top of ICU MessageFormat, aka "MF1".
> For that,
> please see [`@messageformat/core`](https://www.npmjs.com/package/@messageformat/core) instead.

---
_Source: https://npm.io/package/messageformat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
