Registry / productivity / ziffer

ziffer

JSON →
library3.0.0jsnpmunverified

Ziffer is a simple number formatting library for Node.js (current stable version 3.0.0) that supports customizable decimal and thousands separators, prefixes/suffixes, negative number styles (left, right, parentheses), digit grouping, custom digits (e.g., Arabic numerals), and per-call option overrides. It offers a straightforward API with no dependencies, making it a lightweight alternative to Intl.NumberFormat. Released under MIT, it is suitable for formatting currencies, large numbers, and locale-specific outputs.

npm install ziffer
INSTALL
IMPORT
SIG · ZIFFER
Z
ziffer
productivityjavascriptv3.0.0
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.

default
import ziffer from 'ziffer'
const ziffer = require('ziffer')
Package is ESM-only as of v2. CJS require() works in Node but TypeScript may need esModuleInterop.
ziffer (factory function)
const fmt = ziffer({ decimals: 2 })
new ziffer({ decimals: 2 })
Use as a function, not a constructor. Returns a formatter object.

Creating a Euro formatter with default options and formatting a positive and negative number.

import ziffer from 'ziffer'; const euro = ziffer({ inprefix: '€ ', decimals: 2 }); console.log(euro.format(12345.678)); // "€ 12 345,68" console.log(euro.format(-12345.678, { negative: 'paren' })); // "(€ 12 345,68)" const unformatted = euro.unformat('(€ 12 345,68)', { negative: 'paren' }); console.log(unformatted); // -12345.678
Debug
Known issues
breakingVersion 2.x to 3.0: require('ziffer') returns factory function, not constructor. Breaks code using new ziffer().
fix
Replace new ziffer(options) with ziffer(options).
affects: >=2.0.0 <3.0.0
gotchaDefault decimal separator is comma, not period. If you expect period, set decimal: '.' explicitly.
fix
Add { decimal: '.' } to options if period is desired.
affects: >=1.0.0
gotchaThe 'group_except' option sets a lower threshold for grouping; for numbers with fewer digits than group_except, no thousands separator is inserted.
fix
Set group_except to a value less than or equal to the number of integer digits to force grouping.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ziffer is not a constructor
Using new ziffer() after v2 where ziffer is a factory function.
fix
Remove 'new': const fmt = ziffer(options);
Cannot read properties of undefined (reading 'format')
Calling format on undefined; likely forgot to call ziffer() and used module directly.
fix
Ensure you call ziffer(options) to get a formatter object, then call .format().
Unusual output: '12 345,68' instead of '12,345.68'
Default separators: decimal=',' thousands=' '.
fix
Pass { decimal: '.', thousands: ',' } to match US/UK locale.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
51 hits · last 30 days
node
46
OpenAI (training)
1
Resources
packageziffer
ziffer — npm install ziffer · libregistry