NumToPersian

Persian Number to Words Converter:

The Persian Number to Words Converter is a lightweight and versatile library designed to convert numerical values into their Persian (Farsi) word equivalents. Whether you’re working with integers, decimals, or large numbers, this library provides accurate and human-readable Persian representations of numbers.

Key Features:

Example Usage:

import num2persian from 'num2persian';

// Convert integers
console.log(num2persian(123)); // Output: "یکصد و بیست و سه"

// Convert decimals
console.log(num2persian(123.45)); // Output: "یکصد و بیست و سه ممیز چهل و پنج صدم"

// Convert large numbers
console.log(num2persian(1000000)); // Output: "یک میلیون"

// Handle negative numbers
console.log(num2persian(-456)); // Output: "منفی چهارصد و پنجاه و شش"

// Prototype extension
console.log((789).num2persian()); // Output: "هفتصد و هشتاد و نه"

Mixed numbers and letters:

// اعداد به صورت کاراکتر عددی و واحدهای اندازه گیری با حروف
import { num2mixed }  from 'num2persian';
 console.log(num2mixed(123400)); // output: ۱۲۳
 // هزار
 // و
 //  ۴۰۰ 

Helper functions:

import {moneyFormat, fa2en, en2fa}  from 'num2persian';
 console.log(moneyFormat(123000)); // output: ۱۲۳،۰۰۰
 console.log(en2fa(123000)); // output: ۱۲۳۰۰۰
 console.log(fa2en('۱۲۳۰۰۰')); // output: 123000

Installation: Install the library via npm:

npm i num2persian

Testing: The library includes a robust test suite written with Jest to ensure correctness across various scenarios. Run the tests using:

npm test

License: This library is released under the MIT License , making it free to use, modify, and distribute for both personal and commercial purposes.

Whether you’re building a Persian-language application or need a reliable way to display numbers in Persian words, the Persian Number to Words Converter is the perfect tool for the job. Its simplicity, accuracy, and extensibility make it an invaluable addition to any project requiring Persian numeral conversions.

تبدیل عدد به حروف فارسی در جاوا اسکریپت

توانایی پردازش اعداد تا 66 رقم عدد صحیح و 11 رقم اعشار | دسیلیارد

برای استفاده از اعداد بزرگ از نوع داده استرینگ استفاده کنید.

(CDN) :

[https://cdn.jsdelivr.net/gh/mahmoud-eskandari/NumToPersian/dist/num2persian.min.js]

Github Page