Registry / payments / money-formatter

money-formatter

JSON →
library0.1.4jsnpmunverified

A simple JavaScript library for currency formatting that uses ISO 4217 currency codes. Version 0.1.4 is the latest stable release (no recent updates). It formats currencies based on rules from the currency-format package without requiring additional formatting arguments. Differentiators include support for fraction size, HTML output for bidirectional text, and simple formatting with custom symbols. It is compatible with Node.js, Browserify, Webpack, and browsers via UMD.

npm install money-formatter
INSTALL
IMPORT
SIG · MONEY-FORMATTER
M
money-formatter
paymentsjavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

moneyFormatter
const moneyFormatter = require('money-formatter');
import { moneyFormatter } from 'money-formatter';
CommonJS default import.
format
import { format } from 'money-formatter';
const format = require('money-formatter').format;
ES6 named import for tree-shaking.
formatToHTML
import { formatToHTML } from 'money-formatter';
Specific named import. No common mistake.

Demonstrates basic usage of format and formatSimple with different currencies and options.

const moneyFormatter = require('money-formatter'); console.log(moneyFormatter.format('USD', 1234567.89)); // '$1,234,567.89' console.log(moneyFormatter.format('EUR', 123)); // '€123.00' console.log(moneyFormatter.format('JPY', 1000)); // '¥1,000' (no fraction) console.log(moneyFormatter.formatSimple('BTC', 0.5, 4)); // '0.5000 BTC'
Debug
Known issues
breakingThe library may not handle newer currencies or updates to ISO 4217 because it depends on an external package that may be outdated.
fix
Verify currency-format package is up-to-date or manually patch currency data.
affects: >=0.0.0
gotchaWhen using format with fractionSize omitted, it uses the currency's default fraction size from ISO 4217. For currencies like JPY that have 0 decimal places, this works as expected. However, for currencies not in the dataset, it falls back to 2.
fix
Always specify fractionSize if you need explicit control, or ensure currency is in the dataset.
affects: >=0.0.0
gotchaThe format function useAlphaCode option (4th argument) outputs the alphabetic code (e.g., 'USD') instead of the symbol, but it uses basic formatting from formatSimple, which may not include thousand separators.
fix
If you need symbols and proper formatting, do not set useAlphaCode to true.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'currency-format'
The dependency currency-format is not installed when using money-formatter without npm install.
fix
Run 'npm install money-formatter' which installs dependencies automatically, or manually install currency-format.
moneyFormatter.format is not a function
Importing the default export incorrectly in an ES module environment (e.g., import { moneyFormatter } from 'money-formatter' instead of import moneyFormatter from 'money-formatter').
fix
Use default import: import moneyFormatter from 'money-formatter' or require: const moneyFormatter = require('money-formatter').
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
currency-formatrequiredProvides currency formatting rules (symbol, fraction size) based on ISO 4217 codes.
Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
money-formatter — npm install money-formatter · libregistry