@formatjs/intl

v4.1.5 MIT

Internationalize JS apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.

Weekly Downloads
2.0M
Stars
14.7K
Forks
1.4K
Open Issues
25
Gzip Size
13.0 kB
Unpacked Size
43.7 kB
Dependencies
8
Last Updated
2mo ago

@formatjs/intl Download Trends

Download trends for @formatjs/intl03.0M6.1M9.1M12.1MFeb 2025MayAugNovFebApr 2026
@formatjs/intl

About @formatjs/intl

The @formatjs/intl package addresses the complex challenge of internationalizing JavaScript applications. It provides a comprehensive API for formatting dates, numbers, and messages in a way that respects user locale and cultural conventions. This is crucial for building applications that can be easily localized and used by a global audience, moving beyond simple string replacement to true linguistic and cultural adaptation.

Designed with developer experience and internationalization best practices in mind, @formatjs/intl caters to developers building modern web applications, particularly those using frameworks like React. Its core philosophy centers around leveraging the browser's native `Intl` APIs where possible, while providing fallbacks and enhancements for broader compatibility and advanced features like pluralization and select ordinal rules. This makes it suitable for projects requiring robust internationalization support from the outset.

The library offers several key API patterns, including its `formatters` which provide direct access to methods for formatting numbers, dates, relative times, and more. For React applications, `@formatjs/intl` offers hooks like `useIntl` and components like `<FormattedMessage>` which abstract away much of the complexity, allowing developers to declaratively define translatable messages and their associated formats within their components. This pattern simplifies managing translations and dynamic content presentation.

Integration with popular tools and frameworks is a strong suit for @formatjs/intl. It is particularly well-suited for React applications, offering seamless integration via its dedicated React bindings. Beyond React, its core utilities can be integrated into various JavaScript build pipelines and server-side rendering setups. The package also supports common translation management workflows, facilitating the process of collecting and managing translatable strings.

With a weekly download count of 2.7 million and 14.7K GitHub stars, @formatjs/intl is a mature and widely adopted solution. Its unpacked size is 43.7 kB, with a gzipped bundle size of only 13.0 kB, indicating a focus on performance and efficient delivery. The project actively maintains a low number of open issues (16 as of the latest update), suggesting a stable and well-supported ecosystem for developers.

While powerful, developers should be aware that @formatjs/intl might introduce a learning curve due to its comprehensive feature set. For extremely simple use cases that only require basic string lookup without any dynamic formatting or complex pluralization rules, a more lightweight approach might seem appealing. However, the package's robustness in handling locale-specific formats ensures that future needs for advanced internationalization are easily met without requiring a library migration.

When to use

  • When formatting dates, numbers, and currencies according to specific locales, leveraging APIs like `formatDate` and `formatNumber`.
  • When dealing with complex message internationalization that includes pluralization rules using `formatPlural` or `formatMessage` with rich placeholders.
  • When building React applications and you want to declaratively manage translations within components using `<FormattedMessage>` and `useIntl`.
  • When integrating with translation management systems that require a structured approach to message extraction and compilation.
  • When requiring support for ICU Message Syntax for advanced message formatting that includes gender, select, and other complex constructs.
  • When preparing an application for global audiences and needing to ensure consistent, culturally appropriate output across different regions.
  • When needing to handle time zone translations and relative time formatting efficiently with `formatRelativeTime`.

When NOT to use

  • If the primary requirement is simple key-value string translation without any locale-specific formatting, consider a simpler key-value store.
  • If the application has extremely minimal internationalization needs and no plans for future expansion into complex formatting or pluralization.
  • If targeting environments where JavaScript runtime is severely limited and even a 13.0 kB gzipped bundle is prohibitive, explore lighter alternatives.
  • When you only need to translate static UI strings once and do not require dynamic formatting or runtime locale switching.
  • If the project is a build-time only static site generator that pre-renders all content and does not require runtime internationalization capabilities.

@formatjs/intl Alternatives

@formatjs/intl Categories