accounting vs currency.js vs dinero.js vs numeral
JavaScript Currency Formatting Libraries
accountingcurrency.jsdinero.jsnumeralSimilar Packages:

JavaScript Currency Formatting Libraries

These libraries are designed to facilitate the formatting, manipulation, and calculation of currency values in JavaScript applications. They provide developers with tools to handle monetary values effectively, ensuring precision and consistency in financial applications. Each library has its unique features and use cases, catering to different needs in web development.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
accounting04,997-14412 years ago-
currency.js03,367-595 years agoMIT
dinero.js06,726858 kB10a month agoMIT
numeral09,715-3499 years agoMIT

Feature Comparison: accounting vs currency.js vs dinero.js vs numeral

Currency Formatting

  • accounting:

    Accounting.js provides simple currency formatting options, allowing you to format numbers as currency with customizable symbols and decimal places. It supports various formats but lacks advanced features like currency conversion.

  • currency.js:

    Currency.js offers flexible currency formatting with support for multiple currencies. You can easily format values with currency symbols, and it allows for localization options to adapt to different regions.

  • dinero.js:

    Dinero.js excels in currency formatting, providing a clear API for formatting monetary values with precision. It allows for easy formatting of values with currency symbols and supports localization for different currencies.

  • numeral:

    Numeral.js provides extensive formatting options for numbers, including currency formatting. You can format numbers in various ways, making it suitable for applications that require diverse number presentations.

Precision Handling

  • accounting:

    Accounting.js handles precision by using JavaScript's native number type, which can lead to floating-point inaccuracies in certain calculations. It's suitable for basic use cases but may not be ideal for high-precision financial applications.

  • currency.js:

    Currency.js uses a decimal representation to ensure high precision in calculations, making it suitable for applications that require accurate monetary computations. It helps avoid common floating-point errors associated with JavaScript numbers.

  • dinero.js:

    Dinero.js is designed with precision in mind, using integer values to represent currency amounts. This approach eliminates floating-point errors, making it a reliable choice for financial applications that require exact calculations.

  • numeral:

    Numeral.js does not focus specifically on precision handling for currency but provides formatting capabilities that can be used for various numerical types. It is less suited for high-precision financial calculations.

Immutability

  • accounting:

    Accounting.js does not enforce immutability, meaning that values can be modified directly, which may lead to unintended side effects in applications that require strict data integrity.

  • currency.js:

    Currency.js supports immutability by returning new instances for operations instead of modifying existing values. This feature is beneficial for maintaining data integrity in complex applications.

  • dinero.js:

    Dinero.js is built around immutability, ensuring that all operations return new instances. This design choice helps maintain the integrity of monetary values and prevents accidental modifications.

  • numeral:

    Numeral.js does not enforce immutability, allowing for direct modifications of values. This can lead to issues in applications where data integrity is crucial.

Chaining Operations

  • accounting:

    Accounting.js allows for basic chaining of operations, enabling developers to perform multiple formatting and arithmetic tasks in a single line. However, it is limited compared to more advanced libraries.

  • currency.js:

    Currency.js supports method chaining, allowing for a fluent API that makes it easy to perform multiple operations on currency values in a concise manner. This enhances readability and usability in code.

  • dinero.js:

    Dinero.js also supports method chaining, providing a clean and intuitive API for performing operations on monetary values. This feature improves code clarity and makes it easier to manage complex calculations.

  • numeral:

    Numeral.js supports chaining for formatting operations, allowing developers to build complex formatting strings easily. This feature is useful for applications that require customized number presentations.

Use Cases

  • accounting:

    Accounting.js is best suited for simple applications that require basic currency formatting and arithmetic without the need for complex features or dependencies. It's ideal for small projects or prototypes.

  • currency.js:

    Currency.js is suitable for applications that need to handle multiple currencies, perform conversions, and require a robust solution for financial calculations. It's great for e-commerce platforms and financial dashboards.

  • dinero.js:

    Dinero.js is perfect for applications that require high precision in monetary calculations, such as financial software, invoicing systems, and accounting applications. Its immutability and precision make it a reliable choice.

  • numeral:

    Numeral.js is versatile and can be used in various applications that require number formatting, including dashboards, data visualization, and reporting tools. It's not limited to currency but can handle a wide range of numerical formats.

How to Choose: accounting vs currency.js vs dinero.js vs numeral

  • accounting:

    Choose Accounting.js if you need a lightweight library that provides basic currency formatting and arithmetic operations without any dependencies. It's ideal for simple applications where you want to quickly format numbers and perform basic calculations.

  • currency.js:

    Opt for currency.js if you require a more robust solution that supports advanced features like currency conversion, precision handling, and chaining. This library is suitable for applications that need to manage multiple currencies and perform complex calculations.

  • dinero.js:

    Select Dinero.js if you need a comprehensive library for handling monetary values with a focus on immutability and precision. It's perfect for applications that require strict adherence to financial calculations and want to avoid floating-point errors.

  • numeral:

    Use Numeral.js if you need a versatile library for formatting numbers, including currency, percentages, and more. It's great for applications that require extensive number formatting capabilities beyond just currency.

README for accounting

accounting.js is a tiny JavaScript library for number, money and currency parsing/formatting. It's lightweight, fully localisable, has no dependencies, and works great client-side or server-side. Use standalone or as a nodeJS/npm and AMD/requireJS module.

Visit the plugin homepage for demos and documentation: http://openexchangerates.github.io/accounting.js/

Please checkout or download the latest stable tag before using in production. Bug reports and pull requests are welcome.

Maintained by Open Exchange Rates and originally by @josscrowcroft and other contributors.


Works great with:

  • money.js - a tiny (1kb) standalone JavaScript currency conversion library, for web & nodeJS
  • Open Exchange Rates - the free currency conversion data API

Changelog

v0.4.1 - Alias accounting.formatNumber() as accounting.format()

v0.4 - Transferred repository to Open Exchange Rates for ongoing maintenance

v0.3.2 - Fixed package.json dependencies (should be empty object)

v0.3.0

  • Rewrote library structure similar to underscore.js for use as a nodeJS/npm and AMD module. Use npm install accounting and then var accounting = require("accounting"); in your nodeJS scripts.
  • Also works with requireJS or any AMD module loader.
  • unformat now only attempts to parse the number if it's not already a valid number.
  • acounting.unformat now also aliased as acounting.parse
  • Fixed an IE bug in the defaults method

v0.2.2 - Fixed same issue as #Num: #24 in formatNumber; switch to Google Closure Compiler for minified version.

v0.2.1 - Fixed issue #Num: #24 (locally-defined settings object was being modified by formatMoney)

v0.2

  • Rewrote formatting system for formatMoney and formatColumn for better control of string output
  • Now supports separate formats for negative and zero values (optionally) via accounting.settings.currency.format
  • Internal improvements and helper methods

v0.1.4

  • formatMoney recursively formats arrays
  • Added Jasmine test suite (thanks to millermedeiros) and QUnit functionality/speed tests

v0.1.3

  • Added configurable settings object for default formatting parameters.
  • Added format parameter to control symbol and value position (default "%s%v", or [symbol][value])
  • Methods consistently accept object as 2nd parameter, matching/overriding the library defaults

v0.1.2

  • formatColumn works recursively on nested arrays (e.g. accounting.formatColumn( [[1,12,123,1234], [1234,123,12,1]] ), returns matching array with inner columns lined up)
  • Fix rounding in formatNumber

v0.1.1

  • Added toFixed method (accounting.toFixed(value, precision)), which treats floats more like decimals for more accurate currency rounding
  • Minified version preserves semicolons
  • Fixed NaN errors when no value in unformat

v0.1 - First version