# accounting-js

> Number, money and currency formatting library.

Latest version **2.0.3** (published 2025-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install accounting-js
pnpm add accounting-js
yarn add accounting-js
bun add accounting-js
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2025-06-06 |
| First published | 2016-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 45.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 119 |
| Author | Stanislav Lesnikov |
| Maintainers | stah |
| Keywords | es6, modules, rollup, bundle, accounting, number, money, currency, format, utilities, finance, exchange |

## Links

- npm: https://www.npmjs.com/package/accounting-js
- Repository: https://github.com/nashdot/accounting-js
- Homepage: https://nashdot.github.io/accounting-js
- Issues: https://github.com/nashdot/accounting-js/issues
- npm.io page: https://npm.io/package/accounting-js

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2025-06-06
- 2.0.2 — 2025-06-06
- 2.0.1 — 2025-06-06
- 2.0.0 — 2025-06-06
- 1.1.1 — 2016-02-24
- 1.1.0 — 2016-02-24
- 1.0.1 — 2016-02-22
- 1.0.0 — 2016-02-18

## README

[![NPM version](https://img.shields.io/npm/v/accounting-js.svg)](https://www.npmjs.com/package/accounting-js)

**accounting-js** is a tiny JavaScript library for number, money and currency parsing/formatting. It's lightweight, fully localizable, has no dependencies, and works great client-side or server-side. Use standalone or as a nodeJS/npm and AMD/requireJS module.

[Documentation](http://nashdot.github.io/accounting-js)

## Quickstart

### Install

```shell
npm install accounting-js
```

### Use

#### Format number

```javascript
import { formatNumber } from 'accounting-js';

// Default usage
formatNumber(5318008);
// ⇨ 5,318,008

// Custom format
formatNumber(9876543.21, { precision: 3, thousand: " " });
// ⇨ 9 876 543.210
```

#### Format money

```javascript
import { formatMoney } from 'accounting-js';

// Default usage
formatMoney(12345678);
// ⇨ $12,345,678.00

// European formatting (custom symbol and separators)
formatMoney(4999.99, { symbol: "€", precision: 2, thousand: ".", decimal: "," });
// ⇨ €4.999,99
```

#### Convert money to numeric

```javascript
import { unformat } from 'accounting-js';

unformat('£ 12,345,678.90 GBP');
// ⇨ 12345678.9
```

#### Accounting toFixed()

```javascript
// Native toFixed has rounding issues
(0.615).toFixed(2);
// ⇨ '0.61'

// With accounting-js
toFixed(0.615, 2);
// ⇨ '0.62'
```

---
Copyright (c) 2016-present Stanislav Lesnikov, MIT License

Copyright (c) 2014 Open Exchange Rates, MIT License

---
_Source: https://npm.io/package/accounting-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
