Dinero.js is a TypeScript-first library for creating, calculating, and formatting monetary values. It provides immutable money objects that represent amounts in the smallest currency subdivision as integers, ensuring precision and preventing floating-point errors. The library enforces same-currency rules on arithmetic operations and validates currency codes against ISO 4217 definitions at creation time.
The library distinguishes itself through a calculator plugin architecture that delegates arithmetic operations to interchangeable backends, supporting number, bigint, or custom precision libraries. It offers type-safe module variants with separate import paths for number and bigint backends, enabling compile-time type selection without runtime overhead. Dinero.js also includes a proportional allocation algorithm that distributes monetary values across recipients without losing fractional cents, and provides scale-normalized arithmetic that converts amounts to a common decimal scale before addition or subtraction.
The library supports immutable arithmetic operations including addition, subtraction, comparison, proportional allocation, and currency conversion. It generates decimal string representations of monetary amounts without locale-specific formatting, allowing callers to apply their own localization layer. Custom scale configuration enables overriding the default currency exponent to handle currencies with no minor units or non-decimal subdivisions.