num-to-word-rupees
v1.0.2
Published
Convert numbers to words in 12 Indian languages with 100% Python output parity
Maintainers
Readme
num-to-word-rupees
High-performance Node.js / TypeScript port of the popular Python indic-num2words package. Converts numerical digits into words in 12 Indian languages with 100% output equivalence and zero runtime dependencies.
Installation
npm install num-to-word-rupeesOr using yarn/pnpm:
pnpm add num-to-word-rupeesUsage
ES Modules (TypeScript / Modern Node.js)
import { numToWord, num_to_word } from 'num-to-word-rupees';
// Hindi examples:
console.log(numToWord(36, 'hi')); // Output: छत्तीस
console.log(numToWord('४५', 'hi')); // Output: पैतालिस
console.log(numToWord(123456, 'hi')); // Output: एक लाख, तेइस हज़ार, चार सौ, छप्पन
// English (India) with default combiner:
console.log(numToWord(545589, 'en', ', ', ' ')); // Output: five-lakh, forty-five-thousand, five-hundred, eighty-nine
// Custom separator:
console.log(numToWord(795, 'kn', '-')); // Output: ಏಳು ನೂರು-ತೊಂಬತ್ತೈದು
// Python-style alias:
console.log(num_to_word(445951, 'ne')); // Output: चार लाख, पैंतालीस हजार, नौ सय, एकाउन्नCommonJS (Node.js)
const { numToWord } = require('num-to-word-rupees');
console.log(numToWord(100, 'mr')); // Output: शंभरFunction Parameters
num(number | string): The number to be converted (e.g.36,'४५','35,43,57,730').lang(string): Language code (e.g.'hi','en','te').separator(string, optional): String separator between number groups. Default is', '.combiner(string, optional): String combiner for complex numbers. Default is' '(space, automatically defaults to'-'for'en').
Supported Languages
| Code | Language |
| ---- | -------- |
| en | English (India) |
| hi | Hindi |
| ne | Nepali |
| gu | Gujarati |
| mr | Marathi |
| bn | Bengali |
| te | Telugu |
| ta | Tamil |
| kn | Kannada |
| or | Oriya |
| pa | Punjabi |
| ml | Malayalam |
Features
- 100% Python Parity: Built and verified against the original Python
indic-num2wordstest vectors across all 12 languages. - Zero Dependencies: Pure JavaScript/TypeScript implementation.
- Dual Package: Native ESM (
.js) and CommonJS (.cjs) support with TypeScript definitions (.d.ts).
Repository
License
MIT License
