Add accurate money handling to an e-commerce checkout so prices never display floating-point rounding errors.
Build a currency converter that safely adds and compares amounts while keeping the currency attached to each value.
Store invoice line items as immutable currency-aware objects so calculations stay correct throughout a billing flow.
Handle very large transaction amounts using bigint support to avoid precision loss at scale.
Dinero.js is a JavaScript and TypeScript library for representing and working with monetary values. Numbers on their own are not a reliable way to store money: floating-point arithmetic can produce rounding errors, and simple variables carry no information about which currency they represent. Dinero.js addresses this by giving you an object that holds an amount and a currency together, then providing functions to add, subtract, compare, convert, and display those values correctly. Every operation in the library returns a new object rather than modifying the original. If you add two Dinero values together, you get a third value back and the first two remain unchanged. This makes it easier to track money through a calculation without accidentally overwriting data you still need. The library is written with TypeScript and exposes full type information, so editors can catch mistakes like trying to add values in different currencies before the code runs. It also supports working with very large amounts using JavaScript's bigint type, which avoids the precision limits that ordinary numbers have at large scales. Non-decimal currencies, where a unit divides into a different base than 100, are also supported. Dinero.js is packaged so that you can import only the functions you actually use, which keeps the amount of code added to a browser application small. It works in any JavaScript environment: browsers, Node.js, Deno, or wherever JavaScript runs. The library is used in production by WooCommerce, Vercel, Cypress, and several other well-known projects, which gives some indication of its reliability for real payment and commerce work.
← dinerojs on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.