Skip to content

🇧🇩 TypeScript utility for Bangladeshi Taka formatting. Format numbers with the official 3-2-2 comma grouping, convert numbers to words (Bangla + English), and generate currency strings consistently.

License

Notifications You must be signed in to change notification settings

noorjsdivs/currency-formatter-bd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

currency-formatter-bd

Version License Downloads Size


A lightweight, robust, and type-safe TypeScript utility for handling Bangladeshi Currency (Taka) and Number Formats.



English Documentation

🇧🇩 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

✨ Features

  • 🇧🇩 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.

đŸ“Ļ Installation

npm install currency-formatter-bd
# or
yarn add currency-formatter-bd
# or
pnpm add currency-formatter-bd
# or
bun add currency-formatter-bd

đŸ› ī¸ Usage Examples

1. Bangladeshi Comma Formatting

Properly 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!)

2. Number to Words

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: "āĻāĻ• āϕ⧋āϟāĻŋ āϕ⧋āϟāĻŋ"

3. Currency Formatting

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"

âš™ī¸ API Reference

  • formatWithCommas(num: number | string): string
  • toWords(num: number | string): string
  • toWordsBangla(num: number | string): string
  • formatCurrency(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: āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻĢāϰāĻŽā§āϝāĻžāĻŸā§‡ āϟāĻžāĻ•āĻžāϰ āĻ…āĻ™ā§āĻ• āĻĒā§āϰāĻĻāĻ°ā§āĻļāύ āĻ•āϰ⧇āĨ¤



🤝 Contribution / āĻ…āĻŦāĻĻāĻžāύ

We welcome contributions! Please follow these steps:

  1. Clone the repo.
  2. Install dependencies: npm install.
  3. Run tests to ensure everything works: npm test.
  4. Submit a PR.

📄 License

MIT

About

🇧🇩 TypeScript utility for Bangladeshi Taka formatting. Format numbers with the official 3-2-2 comma grouping, convert numbers to words (Bangla + English), and generate currency strings consistently.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published