npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

indian-amount-parser

v1.1.0

Published

Parse Indian-currency amounts (digits or words) from free-form text across 24 languages.

Readme

Indian Amount Parser

npm version License: MIT Tests

Parse amounts from free-form text in 24 languages — digits, words, or mixed. Supports the Indian numbering system (lakh, crore), international currencies, and 12 native digit scripts. Pure ESM, zero dependencies, works in Node.js and browsers.

parseAmountFromText("रुपये दो लाख पचास हजार")  // { amount: 250000, currency: 'INR', language: 'hi', ... }
parseAmountFromText("Rs 2 lakh")                 // { amount: 200000, currency: 'INR', ... }
parseAmountFromText("₹1,50,000")                // { amount: 150000, currency: 'INR', ... }
parseAmountFromText("$2,500")                    // { amount: 2500,   currency: 'USD', ... }
parseAmountFromText("ढाई लाख")                   // { amount: 250000, ... }  (Hindi fractional)
parseAmountFromText("5K and 10L")                // { amount: 1000000, ... } (abbreviations)

Install

npm install indian-amount-parser

Browser (CDN)

UMD (script tag):

<script src="https://unpkg.com/indian-amount-parser/dist/indian-amount-parser.min.js"></script>
<script>
  const result = IndianAmountParser.parseAmountFromText("Rs 2 lakh");
  console.log(result.amount); // 200000
</script>

ESM (modern browsers):

<script type="module">
  import { parseAmountFromText } from "https://esm.sh/indian-amount-parser";
  console.log(parseAmountFromText("पाँच लाख").amount); // 500000
</script>

Quick start

import {
  parseAmountFromText,
  parseAllAmounts,
  createCachedParser,
} from "indian-amount-parser";

// Basic parsing
parseAmountFromText("five lakh");           // { amount: 500000, language: 'en', ... }
parseAmountFromText("पाँच लाख");            // { amount: 500000, language: 'hi', currency: 'INR', ... }
parseAmountFromText("₹ 1,50,000");          // { amount: 150000, currency: 'INR', ... }
parseAmountFromText("two lakh fifty thousand"); // { amount: 250000, ... }

// International currencies
parseAmountFromText("$100");                // { amount: 100, currency: 'USD', ... }
parseAmountFromText("€50");                 // { amount: 50,  currency: 'EUR', ... }
parseAmountFromText("£250");                // { amount: 250, currency: 'GBP', ... }
parseAmountFromText("¥5000");               // { amount: 5000, currency: 'JPY', ... }
parseAmountFromText("200 yuan");            // { amount: 200, currency: 'CNY', ... }

// Native digits (12 scripts)
parseAmountFromText("₹५००");                // { amount: 500, ... }  (Devanagari)
parseAmountFromText("৫০০ টাকা");             // { amount: 500, ... }  (Bengali)
parseAmountFromText("௫௦௦");                 // { amount: 500, ... }  (Tamil)

// Abbreviations
parseAmountFromText("5K");                  // { amount: 5000, ... }
parseAmountFromText("2.5L");                // { amount: 250000, ... }
parseAmountFromText("1.5Cr");               // { amount: 15000000, ... }

// Negative amounts
parseAmountFromText("-500");                // { amount: -500, ... }
parseAmountFromText("(500)");               // { amount: -500, ... }  (accounting style)

// Hindi/Urdu fractions
parseAmountFromText("ढाई लाख");             // { amount: 250000, ... }  (2.5 lakh)
parseAmountFromText("डेढ़ लाख");              // { amount: 150000, ... }  (1.5 lakh)
parseAmountFromText("सवा सौ");              // { amount: 125, ... }     (1.25 × 100)

// Paise subunits
parseAmountFromText("दस रुपये पचास पैसे");  // { amount: 10.5, ... }

// Multiple amounts in one string
parseAllAmounts("I paid 1000, then 2000, then 3000");
// [{ amount: 1000, ... }, { amount: 2000, ... }, { amount: 3000, ... }]

// Force a specific language
parseAmountFromText("पाँच", { language: "hi" });

// No match
parseAmountFromText("this string has no number");
// { amount: null, matched: false, ... }

API

parseAmountFromText(text, options?) → Result

Parses the input text and returns the best-matching amount.

Options:

| Option | Type | Default | Description | | ---------------- | --------- | ------- | ---------------------------------------- | | language | string | auto | Force a specific language code. | | filterYears | boolean | true | Drop 4-digit numbers in 1900–2099. | | filterPhones | boolean | true | Drop 10-digit phone-shaped numbers. | | filterIds | boolean | true | Drop #-prefixed ID numbers. |

Result:

| Field | Type | Description | | ------------ | ------------------ | ------------------------------------------------- | | amount | number \| null | Parsed amount, or null if nothing detected. | | text | string | Original input text. | | language | string \| null | Detected language code ('en', 'hi', ...). | | currency | string \| null | Currency code ('INR', 'USD', 'EUR', etc.). | | confidence | number | 0–1 confidence score. | | rawTokens | string[] | Cleaned tokens used for parsing. | | groups | Array | All candidate groups with their parsed amounts. | | matched | boolean | true if an amount was extracted. |

parseAllAmounts(text, options?) → Result[]

Returns every candidate amount from the text (not just the largest).

normalizeText(text, dictionary?) → string

Returns the cleaned, normalized form of the input. Useful for debugging or custom pipelines.

tokenize(text, dictionary?) → string[]

Splits normalized input into tokens. Currency symbols and punctuation are stripped.

dictionaries / supportedLanguages

Direct access to all 24 dictionary objects and the array of language codes.

createCachedParser(parseFn, options?) → cachedParse

Wraps any parser function with an LRU cache.

const cachedParse = createCachedParser(parseAmountFromText, { maxSize: 500 });
cachedParse("Rs 2 lakh"); // parses
cachedParse("Rs 2 lakh"); // cached
cachedParse.size();        // 1
cachedParse.clear();       // reset

Supported languages

| # | Code | Language | Script | | -- | ----- | ----------------- | -------------- | | 1 | en | English | Latin | | 2 | hi | Hindi | Devanagari | | 3 | bn | Bengali | Bengali | | 4 | te | Telugu | Telugu | | 5 | mr | Marathi | Devanagari | | 6 | ta | Tamil | Tamil | | 7 | gu | Gujarati | Gujarati | | 8 | ur | Urdu | Perso-Arabic | | 9 | kn | Kannada | Kannada | | 10 | or | Odia | Odia | | 11 | ml | Malayalam | Malayalam | | 12 | pa | Punjabi | Gurmukhi | | 13 | as | Assamese | Assamese | | 14 | mai | Maithili | Devanagari | | 15 | sa | Sanskrit | Devanagari | | 16 | kok | Konkani | Devanagari | | 17 | sd | Sindhi | Perso-Arabic | | 18 | ne | Nepali | Devanagari | | 19 | ks | Kashmiri | Perso-Arabic | | 20 | doi | Dogri | Devanagari | | 21 | brx | Bodo | Devanagari | | 22 | sat | Santali | Devanagari | | 23 | mni | Manipuri (Meitei) | Bengali | | 24 | bho | Bhojpuri | Devanagari |

Every language includes full 0–99 number words in native script, plus multipliers for hundred, thousand, lakh, and crore.

Supported currencies

| Symbol | Code | Detection | | ------ | ----- | ---------------------------------- | | | INR | Symbol, Rs, or any native word | | $ | USD | Symbol or "dollar(s)" / "usd" | | | EUR | Symbol or "euro(s)" / "eur" | | £ | GBP | Symbol or "pound(s)" / "sterling" | | ¥ | JPY | Symbol or "yen" / "jpy" | | ¥ | CNY | "yuan" / "rmb" / "renminbi" |

INR is always checked first — Indian currency words take priority.

Indian numbering system

| Western | Indian | Value | | -------: | ---------------: | ------------: | | thousand | thousand | 1,000 | | (none) | lakh | 1,00,000 | | (none) | crore | 1,00,00,000 | | million | 10 lakh | 10,00,000 | | billion | 100 crore / arab | 1,00,00,00,000|

The parser handles lakh and crore as first-class multipliers, including composites like two lakh fifty thousand (250,000).

Testing

npm test

370 tests covering normalization, dictionary validation, parsing, auto-detection, composites, currencies, and edge cases.

Build

npm run build

Outputs to dist/:

  • indian-amount-parser.esm.js — ESM bundle
  • indian-amount-parser.min.js — UMD bundle (minified)
  • indian-amount-parser.js — UMD bundle (dev)

Contributing

To add a new language:

  1. Create src/languages/<code>.js with this shape:

    export default {
      numbers: { /* word → integer, 0–99 */ },
      multipliers: { hundred: 100, thousand: 1000, lakh: 100000, crore: 10000000 },
      connectors: [ /* 'and' equivalents */ ],
      currency: [ /* symbols/words */ ],
      subunits: { /* optional, e.g. paise: 0.01 */ },
    };
  2. Register it in src/languages/registry.js.

  3. Add tests in test/parser.test.js and test/auto-detect.test.js.

  4. Run npm test.

License

MIT — see LICENSE.