# dinerojs/dinero.js

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/dinerojs-dinero-js).**

6,758 stars · 201 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/dinerojs/dinero.js
- Homepage: https://dinerojs.com
- awesome-repositories: https://awesome-repositories.com/repository/dinerojs-dinero-js.md

## Topics

`amount` `currency` `immutable` `javascript` `monetary` `money` `typescript`

## Description

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.

## Tags

### Content Management & Publishing

- [Monetary Value Libraries](https://awesome-repositories.com/f/content-management-publishing/currency-formatting-standards/locale-aware-currency-formatting/monetary-value-libraries.md) — Provides an immutable library for creating, calculating, and formatting monetary values with precision-safe arithmetic.
- [Locale-Aware Currency Formatting](https://awesome-repositories.com/f/content-management-publishing/currency-formatting-standards/locale-aware-currency-formatting.md) — Generates decimal string representations of monetary amounts without locale-specific formatting. ([source](https://dinerojs.com/faq/why-no-currency-formatting))
- [Locale-Independent Decimal Formatters](https://awesome-repositories.com/f/content-management-publishing/currency-formatting-standards/locale-independent-decimal-formatters.md) — Generates decimal strings without locale-specific formatting, leaving localization to the caller.

### Business & Productivity Software

- [Multi-Currency Value Objects](https://awesome-repositories.com/f/business-productivity-software/currency-converters/multi-currency-value-objects.md) — Represents and converts monetary values across currencies with configurable scale and subdivision handling.
- [Currency Validators](https://awesome-repositories.com/f/business-productivity-software/currency-management/currency-validators.md) — Enforces same-currency rules on arithmetic and validates currency codes against ISO 4217.
- [Monetary Calculator Plugins](https://awesome-repositories.com/f/business-productivity-software/tax-calculation-engines/invoice-tax-applications/custom-calculator-plugins/monetary-calculator-plugins.md) — Provides a plugin architecture that delegates arithmetic to interchangeable calculator backends.
- [Subdivision Overrides](https://awesome-repositories.com/f/business-productivity-software/currency-configuration/subdivision-overrides.md) — Ships custom scale configuration to override default currency exponents for non-standard subdivisions. ([source](https://dinerojs.com/core-concepts/amount))

### Data & Databases

- [Monetary Value Objects](https://awesome-repositories.com/f/data-databases/immutable-date-libraries/monetary-value-objects.md) — Provides immutable money objects with safe arithmetic, comparison, and formatting operations.
- [Currency Conversion](https://awesome-repositories.com/f/data-databases/currency-conversion.md) — Converts monetary values between currencies using exchange rates while maintaining precision. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))

### Scientific & Mathematical Computing

- [Scale-Normalized Monetary Arithmetic](https://awesome-repositories.com/f/scientific-mathematical-computing/floating-point-arithmetic/decimal-arithmetic-types/scale-normalized-monetary-arithmetic.md) — Normalizes monetary amounts to a common decimal scale before arithmetic to prevent precision loss.
- [Monetary Arithmetic Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/javascript-math-libraries/monetary-arithmetic-libraries.md) — Handles monetary values with multiple amount types including number, bigint, and custom precision backends.
- [Proportional Money Splitters](https://awesome-repositories.com/f/scientific-mathematical-computing/money-market-deposit-valuations/proportional-money-splitters.md) — Splits monetary values across recipients according to ratios without losing fractional cents. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))
- [Smallest Subdivision Integers](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/arbitrary-precision-arithmetic/integer-based-currency/smallest-subdivision-integers.md) — Represents amounts in the smallest currency subdivision as integers to prevent floating-point errors. ([source](https://dinerojs.com/core-concepts/amount))
- [Monetary Precision Backends](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/arbitrary-precision-arithmetic/monetary-precision-backends.md) — Supports custom calculator plugins for third-party precision libraries like big.js.
- [Currency Scale Configurations](https://awesome-repositories.com/f/scientific-mathematical-computing/matrix-factorization-toolkits/scale-factor-calculators/exponent-scaling/currency-scale-configurations.md) — Overrides default currency exponent scale to handle currencies with no minor units or non-decimal subdivisions. ([source](https://dinerojs.com/getting-started/quick-start))

### Software Engineering & Architecture

- [Monetary Allocation Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/combinatorial-allocation-algorithms/monetary-allocation-algorithms.md) — Implements a proportional allocation algorithm that distributes monetary values without losing fractional cents.
- [Financial Arithmetic Libraries](https://awesome-repositories.com/f/software-engineering-architecture/financial-arithmetic-libraries.md) — Performs arithmetic on monetary values without floating-point errors, supporting proportional allocation and currency conversion.
- [Bigint and Number Variants](https://awesome-repositories.com/f/software-engineering-architecture/library-extension-modules/optional-module-imports/bigint-and-number-variants.md) — Provides separate import paths for number and bigint backends, enabling compile-time type selection. ([source](https://dinerojs.com/getting-started/quick-start))
- [Monetary](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary.md) — Represents monetary values as frozen immutable objects with amount and currency.
- [Addition and Subtraction Operations](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/addition-and-subtraction-operations.md) — Adds or subtracts monetary values immutably, returning new objects without altering originals. ([source](https://dinerojs.com/getting-started/quick-start))
- [Addition Operations](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/addition-operations.md) — Sums money objects with scale normalization and same-currency enforcement. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))
- [Safe Arithmetic Operations](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/safe-arithmetic-operations.md) — Performs immutable arithmetic on monetary values with scale normalization and same-currency enforcement.
- [Value Comparisons](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/value-comparisons.md) — Compares monetary values for equality, greater-than, or less-than relationships. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))
- [Value Constructors](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/value-constructors.md) — Creates immutable money objects from an amount and currency code for safe arithmetic. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))
- [Bigint Monetary Amounts](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/bigint-monetary-amounts.md) — Uses bigint for monetary amounts to safely represent arbitrarily large values beyond number limits. ([source](https://dinerojs.com/guides/precision-and-large-numbers))
- [Custom Calculator Backends](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/custom-calculator-backends.md) — Accepts custom calculator objects to support third-party arithmetic libraries for arbitrary precision. ([source](https://dinerojs.com/guides/precision-and-large-numbers))
- [Customizable Monetary Formatters](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects/monetary/display-formatting/customizable-monetary-formatters.md) — Formats monetary values as strings with optional custom transformer functions. ([source](https://cdn.jsdelivr.net/gh/dinerojs/dinero.js@main/README.md))

### Development Tools & Productivity

- [Monetary Amount Type Selectors](https://awesome-repositories.com/f/development-tools-productivity/custom-selection-actions/custom-selection-types/monetary-amount-type-selectors.md) — Selects between number, bigint, or library-backed types for monetary amounts based on precision needs. ([source](https://dinerojs.com/guides/precision-and-large-numbers))

### Programming Languages & Runtimes

- [Module Variant Imports](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/language-extensions/union-types/type-safe-variants/module-variant-imports.md) — Provides separate import paths for number and bigint backends with compile-time type selection.

### User Interface & Experience

- [Locale-Aware Value Formatting](https://awesome-repositories.com/f/user-interface-experience/value-formatting-tags/locale-aware-value-formatting.md) — Provides locale-aware formatting of monetary values with configurable decimal separators.
