Dinero.js (original) (raw)
Dinero.js
Create, calculate, and format money safely
An immutable library for expressing monetary values in JavaScript and TypeScript.
Designed for humans, ready for agents.
Install
npm install dinero.jsUsage
import { dinero, add, toDecimal } from 'dinero.js';
import { USD } from 'dinero.js/currencies';
const price = dinero({ amount: 1999, currency: USD });
const tax = dinero({ amount: 160, currency: USD });
const total = add(price, tax);
toDecimal(total); // "21.59"Immutable & safe
All operations return new Dinero objects. Your original values are never mutated.
Precise calculations
Handles money as integers in minor units to avoid floating-point precision issues.
Multi-currency
Built-in ISO 4217 currencies with compile-time safety to catch mismatches.
Tree-shakeable
Import only what you need. Functional API designed for optimal bundle size.