v2.0.0
2.0.0 (2026-03-02)
Dinero.js v2 is a complete rewrite of the library, designed from the ground up for modern JavaScript and TypeScript. It replaces the object-oriented, chainable API with a functional architecture of pure, standalone functions that are fully tree-shakeable.
For a step-by-step migration guide, see the upgrade guide.
All chainable methods are now standalone functions. This enables bundlers to tree-shake unused operations.
- import Dinero from 'dinero.js';
- const price = Dinero({ amount: 500, currency: 'USD' });
- price.add(Dinero({ amount: 100, currency: 'USD' }));
+ import { dinero, add } from 'dinero.js';
+ import { USD } from 'dinero.js/currencies';
+ const price = dinero({ amount: 500, currency: USD });
+ add(price, dinero({ amount: 100, currency: USD }));
Currencies are now objects with code, base, and exponent properties instead of ISO 4217 strings. All 166 ISO 4217 currencies ship with the library.
- Dinero({ amount: 500, currency: 'USD' })
+ import { USD } from 'dinero.js/currencies';
+ dinero({ amount: 500, currency: USD })
The precision parameter is renamed to scale. Scale tracks the decimal point position independently of the currency exponent, allowing Dinero to preserve full precision through multi-step calculations.
- Dinero({ amount: 500, currency: 'USD', precision: 3 })
+ dinero({ amount: 500, currency: USD, scale: 3 })
Operations like multiply, allocate, and convert no longer accept floating-point numbers. All fractional values must be passed as scaled amounts to prevent IEEE 754 rounding errors.
- price.multiply(0.055)
+ multiply(price, { amount: 55, scale: 3 })
divide— useallocatefor lossless distributionpercentage— useallocateormultiplytoFormat,toUnit,toRoundedUnit— usetoDecimalortoUnitswith a transformergetAmount,getCurrency,getPrecision— usetoSnapshotgetLocale,setLocale— locale support removed; usetoDecimalwithIntl.NumberFormat- Global defaults (
Dinero.defaultCurrency,Dinero.globalLocale, etc.) — no global state
All public types use a Dinero prefix to avoid naming conflicts:
Calculator→DineroCalculatorCurrency→DineroCurrencySnapshot→DineroSnapshotOptions→DineroOptions
- Node.js 20+ required (v1 had no formal engine requirement)
- Internet Explorer is no longer supported
The dinero.js/bigint entry point provides a dinero function backed by native bigint arithmetic, enabling representation of amounts beyond Number.MAX_SAFE_INTEGER — essential for cryptocurrencies, high-precision finance, and currencies with many decimal places.
import { dinero, add } from 'dinero.js/bigint';
import { USD } from 'dinero.js/bigint/currencies';
const d = dinero({ amount: 999999999999999999n, currency: USD });
The createDinero factory accepts any object implementing DineroCalculator<T>, allowing third-party arbitrary-precision libraries (big.js, JSBI, etc.) as the numeric backend.
The currency.base field supports arrays for currencies with multiple subdivisions (e.g., pre-decimal British pounds: [20, 12] for 20 shillings/pound and 12 pence/shilling). The toUnits function decomposes amounts across all subdivisions.
Currency objects are typed with literal codes (DineroCurrency<number, 'USD'>), enabling TypeScript to catch currency mismatches at compile time — for example, preventing addition of USD and EUR values.
Scale propagates automatically during calculations. The trimScale function reduces it back to the smallest safe representation when needed, eliminating manual precision management.
compare— three-way comparison returning-1 | 0 | 1toDecimal— string decimal representation with optional transformertoUnits— array of amounts per currency subdivisiontrimScale— reduce scale to smallest safe representationnormalizeScale— align multiple Dinero objects to a common scaletransformScale— convert to a specific scale
Eight rounding functions for precise control: up, down, halfUp, halfDown, halfEven, halfOdd, halfTowardsZero, halfAwayFromZero.
The package is marked sideEffects: false. Only the functions you import are included in your bundle.
- allocate: distribute remainder to largest ratio first (#776)
- allocate: prevent infinite loop with large amounts (#771)
- convert: throw when converting between currencies with different bases (#477)
- isPositive: return
falsefor zero values (#728) - toDecimal: handle negative units correctly (#690)
- toDecimal: preserve negative sign for leading zeros (#692)
- toDecimal: do not append decimal string when scale is zero (#751)
- rounding: fix
up,down,halfUphandling of numbers close to 0 (#710, #713) - currencies: use proper base and exponents for MRU and MGA
- currencies: update to ISO 4217 amendments 169-179
The library is distributed as a single dinero.js package with subpath exports:
| Import path | Description |
|---|---|
dinero.js |
Core API (number amounts) |
dinero.js/currencies |
ISO 4217 currency objects |
dinero.js/bigint |
Core API (bigint amounts) |
dinero.js/bigint/currencies |
ISO 4217 currency objects for bigint |
ESM and UMD bundles are available. TypeScript declarations are included.
- Build system: tsdown (powered by Rolldown) for bundling and type generation
- Linting: Oxlint (Rust-based)
- Testing: Vitest with native TypeScript support
- Documentation: new VitePress site at dinerojs.com, with Algolia DocSearch and AskAI
- Node.js: 20+ required
The documentation has been completely rewritten and is available at dinerojs.com. It includes:
- Core concepts guide (amount, currency, scale, mutations, comparisons, formatting)
- Practical guides (serialization, database storage, payment services, cryptocurrencies, and more)
- Full API reference with examples
- Interactive examples: shopping cart (React + Vue), invoice builder, expense splitter, portfolio tracker, and pricing page
v2.0.0-alpha.17
2.0.0-alpha.17 (2026-02-28)
v2.0.0-alpha.16
All @dinero.js/* packages have been removed. The library is now distributed as a single dinero.js package with subpath exports.
import { dinero, add } from '@dinero.js/core';
import { USD } from '@dinero.js/currencies';
import { calculator } from '@dinero.js/calculator-bigint';
import { dinero, add } from 'dinero.js';
import { USD } from 'dinero.js/currencies';
import { dinero as dineroBigint } from 'dinero.js/bigint';
- Uninstall all
@dinero.js/*packages - Install
dinero.js - Update imports as shown above
All public types now use a Dinero prefix to avoid naming conflicts:
Calculator→DineroCalculatorCurrency→DineroCurrencySnapshot→DineroSnapshotOptions→DineroOptions- etc.
- dinero.js: consolidate packages with subpath exports (16b0ad8)
- dinero.js: add granular UMD bundles per RFC #722 (aea9dc2)
- bigint: include bigint currencies in UMD bundle (1054497)
- currencies: add bigint currency definitions (0e4aef8), closes #582
- currencies: add SLE, VED, XAD, XCG, ZWG (amendments 172-179)
- currencies: remove HRK, SLL, CUC, ANG, ZWL (amendments 172-179)
v2.0.0-alpha.15
v2.0.0-alpha.13
2.0.0-alpha.13 (2022-12-19)
v2.0.0-alpha.12
2.0.0-alpha.12 (2022-12-09)
v2.0.0-alpha.11
2.0.0-alpha.11 (2022-12-04)
- ** the
toUnitand thetoFormatfunctions were removed.