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

num2persian

v4.2.0

Published

Number to Persian letter

Readme

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:

  • Comprehensive Number Support: Converts both positive and negative integers. Handles decimal numbers with precision, including the correct placement of "ممیز" (decimal point) and appropriate suffixes like "دهم", "صدم", and "هزارم". Supports large numbers up to 66 digits, including terms like "هزار", "میلیون", "میلیارد", "تریلیون", and beyond.

  • Human-Readable Output: Generates natural Persian phrases using proper grammar and formatting. Ensures culturally accurate representation of Persian numerals, adhering to Persian language conventions.

  • Edge Case Handling: Gracefully handles edge cases like zero (صفر), invalid inputs, and very large numbers exceeding the supported range (with a fallback message: "خارج از محدوده"). Automatically removes trailing zeros in decimal parts for cleaner output.

  • Extensibility: Extends native String and Number prototypes with a .num2persian() method, allowing seamless integration into your codebase. Written in TypeScript, ensuring type safety and compatibility with modern JavaScript/TypeScript projects.

  • Lightweight and Dependency-Free: Minimalistic design with no external dependencies, making it easy to integrate into any project. Optimized for performance without compromising functionality.

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