Skip to content

Dinero.js

Create, calculate, and format money safely

An immutable library for expressing monetary values in JavaScript and TypeScript.

Install

npm install dinero.js@alpha

Usage

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 support for ISO 4217 currencies and custom currency definitions.

Tree-shakeable

Import only what you need. Functional API designed for optimal bundle size.

Released under the MIT License.