RepositoryTypeScript
frolovdev

frolovdev/easymoney

Library for operating with monetary values in JavaScript and Typescript 💵

162stars
9forks
10issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: fowler-money-pattern

#1 Repository of the month

1
TINIX TRENDING·Topic: money-library

#1 Repository of the month

2
TINIX TRENDING·Topic: currency

#2 Repository of the month

easy money logo

codecov License: MIT

Library for operating with monetary values in JavaScript and Typescript

  • Modular. It's written with modular and composable architecture so that your final bundle will be as small as possible.
  • Statically typed. First-class support of Typescript.
  • Immutable: It has a chainable API, but without mutations.
  • Supports big numbers. Support values greater than MAX_SAFE_INTEGER with Bignumber.js
  • Crypto currencies. It has support for custom currencies and formatting them.
  • Big int support. It has a package for supporting new standard of big int out of the box in a separate pacakge.
  • Custom calculators. You can override functionality with your own custom calculator.

📖 Read more

import { createMoney } from '@easymoney/money';

const money1 = createMoney({ amount: 100, currency: 'USD' });

const money2 = createMoney({ amount: 106, currency: 'USD' });

const money3 = money1.add(money2).getAmount();
// => 206
import { createMoneyIntlFormatter } from "@easymoney/formatter"
import { createMoney } from '@easymoney/money';

const money = createMoney({ amount: 5, currency: "USD" });

const formatted = createMoneyIntlFormatter().format(money);
// => "$0.05"
import { createMoneyCryptoFormatter } from "@easymoney/crypto-formatter"
import { createMoney } from '@easymoney/money';
import { cryptoCurrenciesMap } from "@easymoney/currencies"

const money = createMoney({ amount: 5, currency: "LTC" });

const formatted = createMoneyCryptoFormatter().format(money);
// => "0.00000005LTC"
const currencies = [{ minorUnit: 2, code: "XBT" }, { minorUnit: 5, code: "DXBT" }];

const list = createCurrencyList(currencies);

list.getCurrencies();
/**
 * => {
  XBT: { minorUnit: 2, code: "XBT" },
  DXBT: { minorUnit: 5, code: "DXBT" },
};
 */

Requirements

  • For typescript users TS 3.7+
  • If you use @easymoney/bigint-money you need Node Version or Browser Version that supports this proposal

Quick start

npm i @easymoney/money

or

yarn add @easymoney/money

Why

JavaScript developers attempt to use just numbers or strings (i.g. https://github.com/MikeMcl/bignumber.js) to operate with monetary values. I don't think this is the right way, and strings or numbers are not well suited for financial applications for these main reasons:

  • tricky rounding (described here)
  • conversion
  • allocating (dividing money between parties)
  • formatting
  • working with cents (minor units of currency)

The solution to these problems is the Martin Fowler's Money Type from "Patterns of Enterprise Application Architecture".

It's an old pattern that is implemented in many other languages e.g.:

Further reading

How to Operate with Monetary Values in JavaScript

Main features of easymoney

Why rounding is more important than you think

Comparison with dinero.js

easymoneyDinero.js
Typescript✅❌ (only @types/Dinero)
Modularfunctionality is divided by domains, which allows the library to be divided into separate modules as efficiently as possiblewritten as a monolith, one big object with a bunch of functions, no way to divide it into packages by design
Custom currencies support✅❌ (only ISO currencies)
Custom calculators support✅❌
Monetary values greater than MAX_SAFE_INTEGER✅❌
Bigint support✅❌

Packages

PackageVersionDependenciesSize
@easymoney/bigint-moneynpm-bigint-moneydeps-bigint-moneysize-bigint-money
@easymoney/bignumber.jsnpm-bignumberdeps-bignumbersize-bignumber
@easymoney/currenciesnpm-currenciesdeps-currenciessize-currencies
@easymoney/moneynpm-moneydeps-moneysize-money
@easymoney/formatternpm-formatterdeps-formattersize-formatter
@easymoney/crypto-formatternpm-crypto-formatterdeps-crypto-formattersize-crypto-formatter

CDN

Comunity

Learn more

API Reference

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Andrey Frolov

⚠️ 📖 💻

oneyan1

⚠️ 📖 💻

Mikchail

📖

Roman Martynenko

📖

Artem676

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Similar Projects

Discover other similar projects and AI models.

RepositoryGo
Rhymond/go-money

Go implementation of Fowler's Money pattern

1.9k
Apr 29, 2026
RepositoryPHP
moneyphp/money

PHP implementation of Fowler's Money pattern.

4.9k
Nov 23, 2026
RepositoryTypeScript
dinerojs/dinero.js

Create, calculate, and format money in JavaScript and TypeScript

6.8k
Nov 25, 2026
RepositoryTypeScript
xxczaki/cashify

💸 Lightweight currency conversion library, successor of money.js

407
Nov 26, 2026
RepositoryRuby
lineofflight/frankfurter

💱 Currency data API

2.2k
Dec 1, 2026
RepositoryPHP
brick/money

A money and currency library for PHP

1.9k
Oct 6, 2026
RepositoryPHP
florianv/swap

PHP currency conversion library for retrieving exchange rates from 30 providers, with caching and fallback. Maintained since 2014.

1.3k
Nov 26, 2026
RepositorySwift
Flight-School/Money

A precise, type-safe representation of a monetary amount in a given currency

907
Aug 31, 2023
RepositoryPHP
akaunting/laravel-money

Currency formatting and conversion package for Laravel

790
Nov 29, 2026