A lightweight, robust, and type-safe TypeScript utility for handling Bangladeshi Currency (Taka) and Number Formats.
đ§đŠ Made for Bangladesh: Includes specific formatting rules (3,2,2 grouping) and number-to-words conversion in both Bangla and English.
đ Find out more at reactbd.com
- đ§đŠ Comma Formatting: Formats numbers using the South Asian/Bangladeshi numbering system (e.g.,
1,23,45,678). - đ¤ Number to Words:
- English: Converts to standard English words (e.g., "One Hundred Taka").
- Bangla: Converts to accurate Bangla words (e.g., "āĻāĻ āĻļāϤ āĻāĻžāĻāĻž").
- Large Numbers: Supports massive numbers (Trillions, Kotis) with precision (handles strict string inputs).
- ā§ŗ Currency Formatting:
- Fully customizable currency strings.
- Supports symbols (
ā§ŗ,Tk), positioning (left,right), and decimals.
- đ Modern Stack: Built with TypeScript, zero dependencies, ESM/CJS support.
npm install currency-formatter-bd
# or
yarn add currency-formatter-bd
# or
pnpm add currency-formatter-bd
# or
bun add currency-formatter-bdProperly places commas for easy readability in the local context.
import { formatWithCommas } from 'currency-formatter-bd';
console.log(formatWithCommas(12345678));
// Output: "1,23,45,678"
console.log(formatWithCommas('100000000050'));
// Output: "1,00,00,00,00,050" (Handles huge strings!)English (International Style)
import { toWords } from 'currency-formatter-bd';
console.log(toWords(1050));
// Output: "One Thousand Fifty"
console.log(toWords('1098989389384384398434834893'));
// Output: "One Octillion ..." (Handles very large numbers!)Bangla (Local Style)
import { toWordsBangla } from 'currency-formatter-bd';
console.log(toWordsBangla(150));
// Output: "āĻāĻ āĻļāϤ āĻĒāĻā§āĻāĻžāĻļ"
console.log(toWordsBangla(1234567));
// Output: "āĻŦāĻžāϰ⧠āϞāĻā§āώ āĻā§āϤā§āϰāĻŋāĻļ āĻšāĻžāĻāĻžāϰ āĻĒāĻžāĻāĻ āĻļāϤ āϏāĻžāϤāώāĻā§āĻāĻŋ"
// Large numbers (e.g., 100 Crore)
console.log(toWordsBangla('1000000000'));
// Output: "āĻāĻ āĻļāϤ āĻā§āĻāĻŋ"
// Recursive Koti Support (e.g., 1 Crore Crore)
console.log(toWordsBangla('100000000000000'));
// Output: "āĻāĻ āĻā§āĻāĻŋ āĻā§āĻāĻŋ"Format prices exactly how you want them.
import { formatCurrency } from 'currency-formatter-bd';
// Default
console.log(formatCurrency(1500));
// Output: "ā§ŗ 1,500.00"
// Custom Symbol & Position
console.log(formatCurrency(5000, { symbol: 'Tk', position: 'right', spaced: true }));
// Output: "5,000.00 Tk"
// No Decimals
console.log(formatCurrency(199.99, { decimals: 0 }));
// Output: "ā§ŗ 200"formatWithCommas(num: number | string): stringtoWords(num: number | string): stringtoWordsBangla(num: number | string): stringformatCurrency(amount: number | string, options?: CurrencyOptions): string
đ§đŠ āĻŦāĻžāĻāϞāĻžāĻĻā§āĻļā§āϰ āĻāύā§āϝ āϤā§āϰāĻŋ: āĻāϤ⧠āϰāϝāĻŧā§āĻā§ āύāĻŋāϰā§āĻĻāĻŋāώā§āĻ āĻāĻŽāĻž āĻŦāĻŋāύā§āϝāĻžāϏ āύāĻŋāϝāĻŧāĻŽ (ā§Š-⧍-⧍ āĻā§āϰā§āĻĒāĻŋāĻ) āĻāĻŦāĻ āĻŦāĻžāĻāϞāĻž āĻ āĻāĻāϰā§āĻāĻŋ āĻāĻāϝāĻŧ āĻāĻžāώāĻžāϝāĻŧ āϏāĻāĻā§āϝāĻž-āĻĨā§āĻā§-āĻļāĻŦā§āĻĻ āϰā§āĻĒāĻžāύā§āϤāϰāĨ¤
đ āĻāϰāĻ āĻāĻžāύā§āύ reactbd.com āĻāĨ¤
- đ§đŠ āĻŦāĻžāĻāϞāĻžāĻĻā§āĻļā§-āϏā§āĻāĻžāĻāϞ āĻāĻŽāĻž āĻĢāϰāĻŽā§āϝāĻžāĻāĻŋāĻ: āϏā§āĻĨāĻžāύā§āϝāĻŧ āĻĒā§āϝāĻžāĻāĻžāϰā§āύ⧠āĻ āĻā§āĻ āĻā§āϰā§āĻĒ āĻāϰ⧠(āϝā§āĻŽāύ ā§§,ā§¨ā§Š,ā§Ēā§Ģ,ā§Ŧā§ā§Ž)āĨ¤
- đ¤ āϏāĻāĻā§āϝāĻž āĻĨā§āĻā§ āĻļāĻŦā§āĻĻ āϰā§āĻĒāĻžāύā§āϤāϰ:
- āĻāĻāϰā§āĻāĻŋ: āϏāĻāĻā§āϝāĻžāĻā§ āĻĒāĻžāĻ āϝā§āĻā§āϝ āĻāĻāϰā§āĻāĻŋ āĻā§āĻā§āϏāĻā§ āϰā§āĻĒāĻžāύā§āϤāϰ āĻāϰ⧠(āϝā§āĻŽāύ "One Hundred Taka")āĨ¤
- āĻŦāĻžāĻāϞāĻž: āĻā§āĻāĻŋ-āϞāĻā§āώ āϏāĻŋāϏā§āĻā§āĻŽ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻāϰ⧠āϏāĻ āĻŋāĻ āĻŦāĻžāĻāϞāĻž āĻļāĻŦā§āĻĻ (āϝā§āĻŽāύ "āĻāĻ āĻļāϤ āĻāĻžāĻāĻž")āĨ¤
- āĻŦāĻŋāĻļāĻžāϞ āϏāĻāĻā§āϝāĻž āĻšā§āϝāĻžāύā§āĻĄāϞāĻŋāĻ: āϏā§āĻā§āϰāĻŋāĻ āĻāύāĻĒā§āĻā§āϰ āĻŽāĻžāϧā§āϝāĻŽā§ āĻ āϤā§āϝāύā§āϤ āĻŦāĻĄāĻŧ āĻŽāĻžāύāĻā§āϞ⧠āĻāĻžāĻ āĻāϰā§āĨ¤
- ā§ŗ āĻŽā§āĻĻā§āϰāĻž āĻĢāϰāĻŽā§āϝāĻžāĻāĻŋāĻ:
- āĻāĻŋāĻšā§āύ (āϝā§āĻŽāύ ā§ŗ āĻŦāĻž Tk), āĻĒā§āϞā§āϏāĻŽā§āύā§āĻ, āϏā§āĻĒā§āϏāĻŋāĻ āĻāĻŦāĻ āĻĻāĻļāĻŽāĻŋāĻ āύāĻŋāϰā§āĻā§āϞāϤāĻžāϰ āĻāύā§āϝ āύāĻŽāύā§āϝāĻŧ āĻ āĻĒāĻļāύāĨ¤
- đ āĻāϧā§āύāĻŋāĻ āϏā§āĻā§āϝāĻžāĻ: āĻāĻžāĻāĻĒāϏā§āĻā§āϰāĻŋāĻĒā§āĻ āĻĻāĻŋāϝāĻŧā§ āϤā§āϰāĻŋ, āĻā§āύ⧠āĻĄāĻŋāĻĒā§āύā§āĻĄā§āύā§āϏāĻŋ āύā§āĻāĨ¤
npm install currency-formatter-bd
# āĻ
āĻĨāĻŦāĻž
yarn add currency-formatter-bdāĻĻāĻā§āώāĻŋāĻŖ āĻāĻļā§āϝāĻŧ āĻāĻŽāĻž āĻā§āϰā§āĻĒāĻŋāĻ āĻĒā§āϰāϝāĻŧā§āĻ āĻāϰ⧠(ā§Š-⧍-⧍)āĨ¤
import { formatWithCommas } from 'currency-formatter-bd';
console.log(formatWithCommas(12345678));
// āĻāĻāĻāĻĒā§āĻ: "1,23,45,678"
console.log(formatWithCommas('100000000050'));
// āĻāĻāĻāĻĒā§āĻ: "1,00,00,00,00,050"āĻāĻāϰā§āĻāĻŋ (āĻāύā§āϤāϰā§āĻāĻžāϤāĻŋāĻ āϏā§āĻāĻžāĻāϞ)
import { toWords } from 'currency-formatter-bd';
console.log(toWords(1050));
// āĻāĻāĻāĻĒā§āĻ: "One Thousand Fifty"āĻŦāĻžāĻāϞāĻž (āϏā§āĻĨāĻžāύā§āϝāĻŧ āϏā§āĻāĻžāĻāϞ)
import { toWordsBangla } from 'currency-formatter-bd';
console.log(toWordsBangla(150));
// āĻāĻāĻāĻĒā§āĻ: "āĻāĻ āĻļāϤ āĻĒāĻā§āĻāĻžāĻļ"
console.log(toWordsBangla(1234567));
// āĻāĻāĻāĻĒā§āĻ: "āĻŦāĻžāϰ⧠āϞāĻā§āώ āĻā§āϤā§āϰāĻŋāĻļ āĻšāĻžāĻāĻžāϰ āĻĒāĻžāĻāĻ āĻļāϤ āϏāĻžāϤāώāĻā§āĻāĻŋ"
// āĻŦāĻŋāĻļāĻžāϞ āϏāĻāĻā§āϝāĻž (āϝā§āĻŽāύ ā§§ā§Ļā§Ļ āĻā§āĻāĻŋ)
console.log(toWordsBangla('1000000000'));
// āĻāĻāĻāĻĒā§āĻ: "āĻāĻ āĻļāϤ āĻā§āĻāĻŋ"
// ā§§ āĻā§āϝāĻŧāĻžāĻĄā§āϰāĻŋāϞāĻŋāϝāĻŧāύā§āϰ āĻāύā§āϝ āϰāĻŋāĻāĻžāϰā§āϏāĻŋāĻ āĻšā§āϝāĻžāύā§āĻĄāϞāĻŋāĻ
console.log(toWordsBangla('100000000000000'));
// āĻāĻāĻāĻĒā§āĻ: "āĻāĻ āĻā§āĻāĻŋ āĻā§āĻāĻŋ"āĻāĻžāĻāĻžāϰ āĻĒāϰāĻŋāĻŽāĻžāĻŖ āĻā§āĻāĻžāĻŦā§ āĻĒā§āϰāĻĻāϰā§āĻļāύ āĻāϰāĻŦā§āύ āϤāĻž āĻāĻžāϏā§āĻāĻŽāĻžāĻāĻ āĻāϰā§āύāĨ¤
import { formatCurrency } from 'currency-formatter-bd';
// āĻŦā§āϏāĻŋāĻ
console.log(formatCurrency(1500));
// āĻāĻāĻāĻĒā§āĻ: "ā§ŗ 1,500.00"
// āĻāĻžāϏā§āĻāĻŽ
console.log(formatCurrency(5000, { symbol: 'Tk', position: 'right', spaced: true }));
// āĻāĻāĻāĻĒā§āĻ: "5,000.00 Tk"formatWithCommas: āĻŦāĻžāĻāϞāĻžāĻĻā§āĻļā§ āĻāĻŽāĻž āϝā§āĻā§āϤ āϏā§āĻā§āϰāĻŋāĻ āϰāĻŋāĻāĻžāϰā§āύ āĻāϰā§āĨ¤toWords: āĻāύā§āϤāϰā§āĻāĻžāϤāĻŋāĻ āĻĒāĻĻā§āϧāϤāĻŋāϤ⧠āĻāĻāϰā§āĻāĻŋāϤ⧠āϰā§āĻĒāĻžāύā§āϤāϰ āĻāϰā§āĨ¤toWordsBangla: āĻĻā§āĻļā§āϝāĻŧ āĻĒāĻĻā§āϧāϤāĻŋāϤ⧠(āĻā§āĻāĻŋ-āϞāĻā§āώ) āĻŦāĻžāĻāϞāĻžāϝāĻŧ āϰā§āĻĒāĻžāύā§āϤāϰ āĻāϰā§āĨ¤formatCurrency: āĻāĻžāϏā§āĻāĻŽ āĻĢāϰāĻŽā§āϝāĻžāĻā§ āĻāĻžāĻāĻžāϰ āĻ āĻā§āĻ āĻĒā§āϰāĻĻāϰā§āĻļāύ āĻāϰā§āĨ¤
We welcome contributions! Please follow these steps:
- Clone the repo.
- Install dependencies:
npm install. - Run tests to ensure everything works:
npm test. - Submit a PR.
MIT