# @coinify/currency

> Helper functions for managing amounts in different currencies

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

## Install

```sh
npm install @coinify/currency
pnpm add @coinify/currency
yarn add @coinify/currency
bun add @coinify/currency
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.4.12 |
| Published | 2025-11-06 |
| First published | 2017-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/coinify__currency) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 31.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jesper Borgstrup |
| Maintainers | coinifyaps |
| Keywords | currency, coinify, fiat, crypto |

## Links

- npm: https://www.npmjs.com/package/@coinify/currency
- Repository: https://github.com/CoinifySoftware/node-currency
- Homepage: https://github.com/CoinifySoftware/node-currency#readme
- Issues: https://github.com/CoinifySoftware/node-currency/issues
- npm.io page: https://npm.io/package/@coinify/currency

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.4.12 (latest) — 2025-11-06
- 1.4.11 — 2025-08-28
- 1.4.10 — 2025-08-28
- 1.4.9 — 2025-04-30
- 1.4.8 — 2025-04-03
- 1.4.7 — 2025-03-13
- 1.4.6 — 2025-02-13
- 1.4.5 — 2025-02-11
- 1.4.4 — 2025-02-11
- 1.4.3 — 2024-12-12
- 1.4.2 — 2024-11-08
- 1.4.1 — 2024-10-18
- 1.4.0 — 2024-10-04
- 1.3.44 — 2024-04-30
- 1.3.43 — 2024-03-13
- … 52 more at https://npm.io/package/@coinify/currency/versions

## README

# node-currency

[![npm version](https://badge.fury.io/js/%40coinify%2Fcurrency.svg)](https://badge.fury.io/js/%40coinify%2Fcurrency)

## Installation

Run the following command

```
npm install --save @coinify/currency
```

## Usage

```js
const currency = require('@coinify/currency');
```

`currency` exposes the following functions:

### `getDecimalsForCurrency(currency)`
_Returns the number of decimals after the floating point, with which the amount should be formatted, depending on the currency._

### `fromSmallestSubunit(amount, currency)`
_Convert an amount of money from the smallest sub-unit of the currency to the main-unit._

### `toSmallestSubunit(amount, currency)`
_Convert an amount of money from the main-unit of the currency to the smallest sub-unit._

### `convertSubunitAmount(amountSubUnit, rate, fromCurrency, toCurrency)`
_Convert between sub-unit amounts of two currencies with a given rate, correctly converting between sub-units with different decimal amounts._

### `computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, toCurrency, toAmount)`
_Computes a rate between two amounts in two different currencies._

### `isValidCurrency(code)`
_Is the provided currency code a valid currency? (fiat or crypto)_

### `isValidFiatCurrency(code)`
_Is the provided currency code a valid fiat currency?_

### `isValidCryptoCurrency(code)`
_Is the provided currency code a valid crypto currency?_

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