I have some experience using both of these libraries, so I will do my best to explain each of them:

Intl.NumberFormat and decimal.js are both libraries in JavaScript that can be used to format and manipulate numbers. However, while they are similar in some ways, they are very different in others.

Intl.NumberFormat is a built-in JavaScript library that provides localization support for number formatting, including decimal and grouping separators, decimal precision, and currency formatting. It is widely used to format numbers based on a user's language and region.

Decimal.js is a third-party library that provides arbitrary-precision decimal arithmetic for JavaScript. It allows for precise calculations with decimal numbers, which are often required in financial and scientific applications where rounding errors can have significant consequences.

Although Intl.NumberFormat can handle basic currency formatting, it may not be suitable for all use cases. For example, it may not handle more complex currency formatting requirements, such as rounding rules or multiple currencies in the same document. In such cases, decimal.js can provide more precise and flexible currency handling capabilities.

I hope this answered your question!

Answer from Promaster on Stack Overflow
🌐
DEV Community
dev.to › fvictorio › a-comparison-of-bignumber-libraries-in-javascript-2gc5
A comparison of BigNumber libraries in JavaScript - DEV Community
November 28, 2020 - Which library you'll choose will depend, of course, on your use case, but my advice is that you can't go wrong with big.js. The API is very nice and its feature set should cover most use cases. You can check it out and, if you need a feature that it doesn't support or if it has some behavior that makes life harder for you, then you can check some of the other ones. For example, if you are using 10 significant digits, then Decimal('22222222222222222222').div(2).toFixed(0) is equal to 11111111110000000000.
🌐
Medium
medium.com › @josephgathumbi › decimal-js-vs-c1471b362181
Decimal.js vs. BigNumber.js: Which One Should You Use for High-Precision Arithmetic and Large Numbers? | by Joseph | Medium
January 30, 2025 - Decimal.js: Offers unlimited precision by default, which can be adjusted globally or per operation. BigNumber.js: Precision is configurable but usually capped at a practical limit to balance performance and accuracy. Winner: It’s a tie. Both libraries provide configurable precision to suit most high-precision needs. JavaScript’s Number type is limited to 53-bit integers, meaning numbers larger than 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER) lose accuracy.
Top answer
1 of 2
1

I have some experience using both of these libraries, so I will do my best to explain each of them:

Intl.NumberFormat and decimal.js are both libraries in JavaScript that can be used to format and manipulate numbers. However, while they are similar in some ways, they are very different in others.

Intl.NumberFormat is a built-in JavaScript library that provides localization support for number formatting, including decimal and grouping separators, decimal precision, and currency formatting. It is widely used to format numbers based on a user's language and region.

Decimal.js is a third-party library that provides arbitrary-precision decimal arithmetic for JavaScript. It allows for precise calculations with decimal numbers, which are often required in financial and scientific applications where rounding errors can have significant consequences.

Although Intl.NumberFormat can handle basic currency formatting, it may not be suitable for all use cases. For example, it may not handle more complex currency formatting requirements, such as rounding rules or multiple currencies in the same document. In such cases, decimal.js can provide more precise and flexible currency handling capabilities.

I hope this answered your question!

2 of 2
0

I agree to Promaster's answer, it's also worth noting that using the decimal.js library may have performance implications, as it is a third-party library that requires additional processing overhead compared to the built-in Intl.NumberFormat library. Therefore, you should consider the specific requirements of your application when deciding whether to use decimal.js or Intl.NumberFormat.

The main benefit of using the decimal.js library over Intl.NumberFormat is the ability to perform precise mathematical operations on decimal numbers. If your application requires this level of precision, then decimal.js may be a better choice. However, if your application only requires formatting numbers for display, then Intl.NumberFormat may be sufficient.

🌐
NPM Compare
npm-compare.com › big.js,bignumber.js,decimal.js,decimal.js-light
decimal.js vs bignumber.js vs big.js vs decimal.js-light | JavaScript Arbitrary-Precision Decimal Libraries
It offers a comprehensive set of features, including support for various mathematical functions, rounding modes, and conversion methods. Decimal.js is particularly suited for applications that require extensive mathematical operations, making it a strong alternative to bignumber.js for more complex calculations. mathjs is a powerful and flexible mathematics library for JavaScript and Node.js.
🌐
npm Trends
npmtrends.com › big.js-vs-bignumber.js-vs-decimal.js-vs-mathjs
big.js vs bignumber.js vs decimal.js vs mathjs | npm trends
Comparing trends for big.js 7.0.1 which has 23,991,770 weekly downloads and 5,148 GitHub stars vs. bignumber.js 9.3.1 which has 25,343,914 weekly downloads and 6,968 GitHub stars vs. decimal.js 10.6.0 which has 34,483,615 weekly downloads and 7,114 GitHub stars vs. mathjs 15.1.0 ...
🌐
npm
npmjs.com › package › decimal.js
decimal.js - npm
... The library is similar to bignumber.js, but here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar to Python's decimal module) rather than just those ...
      » npm install decimal.js
    
Published   Jul 06, 2025
Version   10.6.0
Author   Michael Mclaughlin
🌐
GitHub
github.com › MikeMcl › decimal.js
GitHub - MikeMcl/decimal.js: An arbitrary-precision Decimal type for JavaScript · GitHub
... The library is similar to bignumber.js, but here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar to Python's decimal module) rather than just those ...
Author   MikeMcl
🌐
Reddit
reddit.com › r/node › best package for money arithmetic?
r/node on Reddit: Best Package for Money Arithmetic?
March 7, 2017 -

Hey Node Friends. I'm going to have to build a system that deals with currency and money arithmetic for the first time. We are all aware that using floating points is problematic for these sort of calculations.

Is there a preferred library by the community that deals with this stuff?

The best I've found on my own is big.js

Update: Unlike the comments below, I didn't use float or integers as that is what I was trying not to use in the first place.

mathjs was a suggestion, but that depends on decimal.js anyway so you could just use decimal.js directly.

I read over this comparison between decimal.js, big.js and bignumber.js. I went with big.js in the end, just because it's the more minimal version of the 3 that does everything I need (ex. I only need to use base 10)

Thanks for the help!

Find elsewhere
🌐
GitHub
github.com › tc39 › proposal-decimal
GitHub - tc39/proposal-decimal: Built-in exact decimal numbers for JavaScript · GitHub
decimal128.js is an npm package that implements Decimal128 in JavaScript (more precisely, the variant of Decimal128 that we envision for this proposal) We are looking for volunteers for writing a polyfill along the lines of JSBI for both alternatives, see #17
Author   tc39
🌐
GitHub
github.com › MikeMcl › big.js › issues › 45
big.js vs. bignumber.js vs. decimal.js? · Issue #45 · MikeMcl/big.js
February 18, 2015 - There was an error while loading. Please reload this page · Suggestion: describe in the readme how these three libraries differ. AFAICT, big.js only supports base 10, whereas bignumber.js supports arbitrary bases. But what distinguishes decimal.js from big.js
Published   Apr 11, 2015
🌐
Medium
miladezzat.medium.com › mastering-money-calculations-in-javascript-the-best-libraries-compared-8e4ae03dac58
Mastering Money Calculations in JavaScript: The Best Libraries Compared | by Milad Fahmy | Medium
December 1, 2024 - This behavior occurs because JavaScript uses binary floating-point numbers, which aren’t precise for decimal values. Fortunately, several libraries are designed to overcome these limitations, especially for money-related use cases. In this article, we’ll explore Decimal.js, Big.js, Dinero.js, Currency.js, and Accounting.js, comparing their features to help you choose the best one for your needs.
🌐
Progress
progress.com › blogs › decimals-no-limitations-javascript
Decimals with No Limitations in JavaScript
November 13, 2024 - In conclusion, as we had seen in the previous blog, we can have computation issues with JavaScript numbers. Corticon.js provides support for commercial and scientific applications using a robust decimal type that avoids issues with JavaScript numbers.
🌐
npm Trends
npmtrends.com › bignumber.js-vs-decimal.js-vs-mathjs-vs-numeral-vs-numeraljs
bignumber.js vs decimal.js vs mathjs vs numeral vs numeraljs | npm trends
Comparing trends for bignumber.js 9.3.1 which has 14,488,094 weekly downloads and 6,960 GitHub stars vs. decimal.js 10.6.0 which has 18,051,401 weekly downloads and 7,092 GitHub stars vs. mathjs 15.1.0 which has 799,866 weekly downloads and 14,971 GitHub stars vs. numeral 2.0.6 which has 803,231 weekly downloads and 9,731 GitHub stars vs. numeraljs 1.5.6 which has 1,775 weekly downloads and 1 GitHub stars.
🌐
GitHub
github.com › MikeMcl › decimal.js-light
GitHub - MikeMcl/decimal.js-light: The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript. · GitHub
The light version of decimal.js, an arbitrary-precision Decimal type for JavaScript. - MikeMcl/decimal.js-light
Author   MikeMcl
🌐
npm Trends
npmtrends.com › big.js-vs-bigdecimal-vs-bignumber.js-vs-decimal.js-vs-mathjs
big.js vs bigdecimal vs bignumber.js vs decimal.js vs mathjs | npm trends
Comparing trends for big.js 7.0.1 which has 25,720,379 weekly downloads and 5,155 GitHub stars vs. bigdecimal 0.6.1 which has 5,985 weekly downloads and 243 GitHub stars vs. bignumber.js 9.3.1 which has 28,375,466 weekly downloads and 6,971 GitHub stars vs. decimal.js 10.6.0 which has 42,295,481 weekly downloads and 7,140 GitHub stars vs. mathjs 15.1.1 which has 2,057,021 weekly downloads and 15,002 GitHub stars.
🌐
Babylon.js
forum.babylonjs.com › questions
Some recommended big decimals library to use besides BabylonJs? - Questions - Babylon.js
May 30, 2021 - Hello. I’m working in a motion class for my babylonjs project and I have some issues interpolating arrays of numbers. I believe this is caused for the javascript floating point precision issues: [Link] Is there some r…
🌐
Reddit
reddit.com › r/incremental_games › break_infinity.js - a performance-designed replacement for decimal.js for incremental games that use very large numbers
r/incremental_games on Reddit: break_infinity.js - a performance-designed replacement for decimal.js for incremental games that use VERY large numbers
October 8, 2017 -

https://github.com/Patashu/break_infinity.js

I made this library because decimal.js is very slow, both because it focused on arbitrary precision, and because its functions were not coded with performance in mind to begin with.

By relaxing the arbitrary precision requirement (mantissa is now just a javascript Number, rather than an array of strings, and exp and pow only guarantee about 9 decimal places of accuracy), compared to decimal.js, operations of break_infinity.js are anywhere from 50x to 1000x faster.

How fast is it in practice? Antimatter Dimensions swapped from decimal.js to break_infinity.js in its Eternity Update that came out today ( https://www.reddit.com/r/incremental_games/comments/7grvhl/antimatter_dimensions_eternity_update/ ), and in doing so, the time spent in scripts was reduced to 22% of what it used to be. Obviously if your incremental game is not as math-heavy as Antimatter Dimensions it won't benefit to the same extent, but performance is performance.

Like decimal.js, break_infinity.js handles numbers as large as 1e(9e15). Above that (if you even GET that far), you should use break_break_infinity.js instead, which goes up to 1e(1.79e308), though note that it hasn't been thoroughly tested yet, and obviously it will lose on performance compared to break_infinity.js since it uses a big-integer library for the exponent instead of just a Number.

If you find any bugs or wish to contribute, check out the issues on the github repository ( https://github.com/Patashu/break_infinity.js/issues ) or open a pull request (or message me on Reddit, I guess).

🌐
Best of JS
bestofjs.org › projects › bigjs
Best of JS • Big.js
Trends and data about Big.js project. A small, fast library for arbitrary-precision decimal arithmetic