Registry / payments / geld
library4.0.0jsnpmunverified

geld is a minimal currency formatter for Node.js (>=22) and browsers, providing a simple function to format numbers as currency strings. It offers options for currency symbol, decimal and group separators, position of currency symbol, and a special zero-decimals placeholder. The package is ESM-only (CJS requires dynamic import) and ships TypeScript type definitions. Version 4.0.0 is the latest stable release. Its key differentiator is extreme minimalism and opinionated German defaults (Euro, comma decimal, dot thousands, no-break space).

npm install geld
INSTALL
IMPORT
SIG · GELD
G
geld
paymentsjavascriptv4.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 geld from 'geld'
const geld = require('geld')
ESM-only package; use dynamic import if in a CommonJS context: import('geld').then(m => m.default).
geld type (TypeScript)
import type { GeldOptions } from 'geld'
Type-only import for the options interface; not exported as a value.
GeldOptions
import type { GeldOptions } from 'geld'
The options type is exported only as a type; use `import type` to avoid runtime errors.

Demonstrates basic usage with default German Euro formatter and custom options with US dollar formatting.

import geld from 'geld'; const price1 = geld(42.23); console.log(price1); // => '42,23 €' const price2 = geld(42, { zeroDecimals: '–' }); console.log(price2); // => '42,– €' const price3 = geld('1234.56', { currency: '$', currencyPosition: 'before', decimalSeparator: '.', orderSeparator: ',', decimals: 2, space: ' ' }); console.log(price3); // => '$ 1,234.56'
Debug
Known issues
breakingVersion 4.0.0 drops support for Node.js <22. Older Node.js versions will error at import.
fix
Upgrade to Node.js 22 or later, or stay on geld v3.x if you need older Node.
affects: >=4.0.0
breakingVersions 4.0.0 is ESM-only; CJS require() throws ERR_REQUIRE_ESM.
fix
Use dynamic import: `const geld = await import('geld');` or set `"type": "module"` in package.json.
affects: >=4.0.0
gotchaThe default decimal separator is comma (','), not period ('.'), which may cause confusion for US users.
fix
Explicitly set `{ decimalSeparator: '.' }` if you need a period decimal.
affects: >=1.0.0
gotchaThe default space between value and currency is a non-breaking space (U+00A0), not a regular space.
fix
Override with `{ space: ' ' }` if you want a regular space.
affects: >=1.0.0
deprecatedThe option `orderSeparator` is named after 'order' (German for 'thousands'); this is not intuitive in English.
fix
No deprecation planned; it is stable. Document clearly for international teams.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/geld/index.js from /path/to/project/index.js not supported.
Attempting to require() an ESM-only package (v4) in a CommonJS module.
fix
Use dynamic import: `const geld = await import('geld');` or convert your project to ESM.
TypeError: geld is not a function
Using a default import after a CJS require() that returns an object with a default property.
fix
Use `const geld = require('geld').default;` or use dynamic import.
SyntaxError: Unexpected token 'export' (or similar) in older Node
Node.js version <22 does not support ESM syntax used in geld v4.
fix
Upgrade Node.js to ^22.0.0 or use geld v3 (which may support CJS).
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
32
Resources
packagegeld
geld — npm install geld · libregistry