npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arraypress/stripe-currencies

v2.1.0

Published

Stripe currency formatting, conversion, and validation. All 136 currencies.

Readme

@arraypress/stripe-currencies

Stripe currency formatting, conversion, and validation. All 136 Stripe-supported currencies with correct symbols, decimal handling, and display names.

Zero dependencies. Works in Node.js, Cloudflare Workers, Deno, Bun, and browsers.

Installation

npm install @arraypress/stripe-currencies

Usage

import {format, formatRecurring, formatPlain, formatWithCode} from '@arraypress/stripe-currencies';

// All amounts are in smallest unit (cents) — as Stripe returns them

// Format with symbol
format(1999, 'usd')     // 'US$19.99'
format(1500, 'gbp')     // '£15.00'
format(1000, 'jpy')     // '¥1,000'      (zero-decimal)
format(5000, 'bhd')     // 'BD5.000'     (three-decimal)
format(-1999, 'usd')    // '-US$19.99'

// Recurring/subscription prices
formatRecurring(999, 'usd', 'month')       // 'US$9.99/mo'
formatRecurring(2999, 'usd', 'year')       // 'US$29.99/yr'
formatRecurring(999, 'usd', 'month', 3)    // 'US$9.99 every 3 months'

// Without symbol
formatPlain(1999, 'usd')      // '19.99'

// With code
formatWithCode(1999, 'usd')   // '19.99 USD'

API

Formatting

All formatting functions take amount in the smallest unit (cents, pence, etc.) as Stripe returns.

| Function | Example | Result | |-------------------------------|---------------|---------------| | format(1999, 'usd') | With symbol | 'US$19.99' | | format(1000, 'jpy') | Zero-decimal | '¥1,000' | | format(5000, 'bhd') | Three-decimal | 'BD5.000' | | formatPlain(1999, 'usd') | No symbol | '19.99' | | formatWithCode(1999, 'usd') | Code suffix | '19.99 USD' |

Recurring Prices

Format subscription/recurring prices with billing interval suffixes.

import {formatRecurring} from '@arraypress/stripe-currencies';

// Standard intervals
formatRecurring(999, 'usd', 'month')       // 'US$9.99/mo'
formatRecurring(2999, 'usd', 'year')       // 'US$29.99/yr'
formatRecurring(500, 'gbp', 'week')        // '£5.00/wk'
formatRecurring(100, 'usd', 'day')         // 'US$1.00/day'

// Custom interval counts
formatRecurring(999, 'usd', 'month', 3)    // 'US$9.99 every 3 months'
formatRecurring(999, 'usd', 'year', 2)     // 'US$9.99 every 2 years'
formatRecurring(500, 'usd', 'week', 2)     // 'US$5.00 every 2 weeks'

// Zero-decimal currencies
formatRecurring(1000, 'jpy', 'month')      // '¥1,000/mo'

// No interval returns plain format
formatRecurring(999, 'usd', null)          // 'US$9.99'

Currency Data

import {getSymbol, getName, getDecimals} from '@arraypress/stripe-currencies';

getSymbol('gbp')     // '£'
getName('eur')       // 'Euro'
getDecimals('jpy')   // 0
getDecimals('usd')   // 2
getDecimals('bhd')   // 3

Conversion

Convert between decimal amounts and Stripe's smallest unit representation.

import {toSmallestUnit, fromSmallestUnit} from '@arraypress/stripe-currencies';

toSmallestUnit(19.99, 'usd')    // 1999
toSmallestUnit(1000, 'jpy')     // 1000
toSmallestUnit(5.123, 'bhd')    // 5123

fromSmallestUnit(1999, 'usd')   // 19.99
fromSmallestUnit(1000, 'jpy')   // 1000
fromSmallestUnit(5123, 'bhd')   // 5.123

Validation

import {isSupported, isZeroDecimal} from '@arraypress/stripe-currencies';

isSupported('usd')     // true
isSupported('xyz')     // false

isZeroDecimal('jpy')   // true  (JPY, KRW, VND, etc.)
isZeroDecimal('usd')   // false

Stripe Decimal Handling

Most currencies use 2 decimal places. Exceptions:

  • Zero-decimal (0): JPY, KRW, CLP, PYG, VND, VUV, RWF, BIF, DJF, GNF, KMF, MGA, XAF, XOF, XPF
  • Three-decimal (3): BHD, KWD, OMR, JOD, TND
  • Logically zero but Stripe uses 2: ISK, UGX

TypeScript

Full type definitions included.

import {format, formatRecurring, isSupported} from '@arraypress/stripe-currencies';

const price: string = format(1999, 'usd');
const monthly: string = formatRecurring(999, 'usd', 'month');
const valid: boolean = isSupported('gbp');

License

MIT