Registry / finance / rupee-formatter

rupee-formatter

JSON →
library1.0.5jsnpmunverified

A simple Indian currency formatter that converts numbers to Indian numbering system (lakhs, crores) with ₹ symbol, locale-aware grouping, and decimal support. Current version 1.0.5 is stable with minimal updates. Key differentiator: lightweight, zero-dependency, supports numbers and strings, handles negative values and large numbers up to billions. Suitable for Node.js and browser environments.

npm install rupee-formatter
INSTALL
IMPORT
SIG · RUPEE-FORMATTER
R
rupee-formatter
financejavascriptv1.0.5
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 (function)
import rupeeFormatter from 'rupee-formatter'
import { rupeeFormatter } from 'rupee-formatter'
The package exports a default function, not a named export. Named import will result in undefined.
default (CommonJS)
const rupeeFormatter = require('rupee-formatter')
const { rupeeFormatter } = require('rupee-formatter')
In CommonJS, destructuring the default export fails because it's not a named export.
TypeScript usage
import rupeeFormatter from 'rupee-formatter'
import * as rupeeFormatter from 'rupee-formatter'
The package does not ship TypeScript types; you may need to create a declaration file or use // @ts-ignore.

Demonstrates formatting various Indian currency values including decimals, large numbers, negatives, and edge cases like empty string and invalid input.

import rupeeFormatter from 'rupee-formatter'; console.log(rupeeFormatter(12543.66)); // "₹ 12,543.66" console.log(rupeeFormatter("1753676545643.345434")); // "₹ 17,53,67,65,45,643.345434" console.log(rupeeFormatter(-54980.6789)); // "₹ -54,980.6789" console.log(rupeeFormatter("")); // "₹ -" (edge case) console.log(rupeeFormatter("abc")); // "₹ NaN" (no validation)
Debug
Known issues
gotchaEmpty string input returns '₹ -' instead of throwing an error or returning empty.
fix
Validate input before passing: if (!input) return '';
affects: *
gotchaNon-numeric string input returns '₹ NaN' (e.g., rupeeFormatter("abc") → '₹ NaN').
fix
Use isNaN or typeof check to handle invalid inputs.
affects: *
gotchaThe package does not support formatting of numbers as strings with thousands separators beyond what is typical for Indian numbering (no lakh/crore grouping for decimals).
fix
No fix; consider alternatives like Intl.NumberFormat for more control.
affects: *
deprecatedPackage has not been updated since 2019; no TypeScript definitions, no ES module build (only CommonJS).
fix
Use Intl.NumberFormat with 'en-IN' locale for modern projects.
affects: <=1.0.5
Errors
Common errors & fixes
TypeError: rupeeFormatter is not a function
Using named import instead of default import in ESM.
fix
Change import to: import rupeeFormatter from 'rupee-formatter'
Cannot find module 'rupee-formatter' or its corresponding type declarations.
Package lacks TypeScript type definitions.
fix
Add a declaration file: declare module 'rupee-formatter'; or use @ts-ignore.
₹ NaN
Passing non-numeric string to the formatter.
fix
Ensure input is a valid number: parseFloat(input) or use regex.
₹ -
Passing empty string or falsy value.
fix
Filter falsy inputs: if (!input && input !== 0) return '';
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
rupee-formatter — npm install rupee-formatter · libregistry