A TypeScript library for converting numbers between Indian and International number formatting systems.
This library is particularly useful for applications that need to display numbers in different regional formats, such as financial applications, e-commerce platforms, or any application serving users across different regions.
- Node.js (v18 or higher)
- pnpm (recommended) or npm/yarn
npm install number-fmt
# or
pnpm install number-fmt
# or
yarn add number-fmtFor detailed usage examples and API documentation, see the Plugins README.
Please read the contributing guide.
Licensed under the MIT license.
Converts numbers from International format (or raw numbers) to Indian number format.
Examples:
import { convertToIndianFormat } from "number-fmt";
// Basic conversions
convertToIndianFormat("123456"); // "1,23,456"
convertToIndianFormat("1234567"); // "12,34,567"
convertToIndianFormat("12345678"); // "1,23,45,678"
convertToIndianFormat("123456789"); // "12,34,56,789"
// With existing commas (International format)
convertToIndianFormat("1,234,567"); // "12,34,567"
convertToIndianFormat("123,456"); // "1,23,456"Converts numbers from Indian format (or raw numbers) to International number format.
Examples:
import { convertToInternationalFormat } from "number-fmt";
// Converting from Indian format
convertToInternationalFormat("1,00,000"); // "100,000"
convertToInternationalFormat("12,34,567"); // "1,234,567"
convertToInternationalFormat("1,00,00,000"); // "10,000,000"
convertToInternationalFormat("9,99,99,999"); // "99,999,999"
// Converting from raw numbers (no commas)
convertToInternationalFormat("100000"); // "100,000"
convertToInternationalFormat("1000000"); // "1,000,000"
convertToInternationalFormat("1234567"); // "1,234,567"