PHPackages                             devhamidshahbazi/number-normalizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. devhamidshahbazi/number-normalizer

ActiveLaravel-package[Utility &amp; Helpers](/categories/utility)

devhamidshahbazi/number-normalizer
==================================

Laravel package to automatically normalize any non-English digits (Persian, Arabic, Urdu, etc.) to English numbers in all requests

v1.1.0(1mo ago)01MITPHPPHP ^8.1

Since Jun 28Pushed 1mo agoCompare

[ Source](https://github.com/DevHamidShahbazi/number-normalizer)[ Packagist](https://packagist.org/packages/devhamidshahbazi/number-normalizer)[ RSS](/packages/devhamidshahbazi-number-normalizer/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Number Normalizer 🌍
===================

[](#number-normalizer-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/da76423bb03959e22843cd92614f4595376a5dd1b28826e6f5288f6f6cb92d0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657668616d69647368616862617a692f6e756d6265722d6e6f726d616c697a65722e737667)](https://packagist.org/packages/devhamidshahbazi/number-normalizer)[![Total Downloads](https://camo.githubusercontent.com/8fcab1efe8ce252a041baa82f8b3ad43be44be13c6469d883adc46e55e8feafc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657668616d69647368616862617a692f6e756d6265722d6e6f726d616c697a65722e737667)](https://packagist.org/packages/devhamidshahbazi/number-normalizer)[![License](https://camo.githubusercontent.com/2ffebd78cc05f36d457018efc5844405a302e36888ed53ad3813cae5adc1d9b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64657668616d69647368616862617a692f6e756d6265722d6e6f726d616c697a65722e737667)](https://github.com/DevHamidShahbazi/number-normalizer/blob/main/LICENSE)

**Laravel package to automatically normalize any non-English digits to English numbers in all requests.**

✨ Features
----------

[](#-features)

- 🌍 **10 Languages Supported** - Persian, Arabic, Urdu, Hindi, Bengali, Gujarati, Thai, Khmer, Lao, Myanmar
- 🚀 **Auto Middleware** - Automatically normalizes all incoming requests
- ⚙️ **Fully Configurable** - Add custom languages, exclude routes, choose language combinations
- 🔌 **Extensible** - Easy to add new languages via config or code
- 🎯 **Zero Configuration** - Works out of the box with Persian and Arabic

📦 Installation
--------------

[](#-installation)

```
composer require devhamidshahbazi/number-normalizer
```

Publish the config file:

```
php artisan vendor:publish --tag=number-normalizer-config
```

🌍 Supported Languages
---------------------

[](#-supported-languages)

### Languages with Custom Digits (10 Languages)

[](#languages-with-custom-digits-10-languages)

\#LanguageDigitsExample1**Persian**`۰۱۲۳۴۵۶۷۸۹``۱۲۳` → `123`2**Arabic**`٠١٢٣٤٥٦٧٨٩``١٢٣` → `123`3**Urdu**`۰۱۲۳۴۵۶۷۸۹``۱۲۳` → `123`4**Hindi**`०१२३४५६७८९``१२३` → `123`5**Bengali**`০১২৩৪৫৬৭৮৯``১২৩` → `123`6**Gujarati**`૦૧૨૩૪૫૬૭૮૯``૧૨૩` → `123`7**Thai**`๐๑๒๓๔๕๖๗๘๙``๑๒๓` → `123`8**Khmer**`០១២៣៤៥៦៧៨៩``១២៣` → `123`9**Lao**`໐໑໒໓໔໕໖໗໘໙``໑໒໓` → `123`10**Myanmar**`၀၁၂၃၄၅၆၇၈၉``၁၂၃` → `123`⚙️ Configuration
----------------

[](#️-configuration)

File: `config/number-normalizer.php`

```
// Active languages (merged and applied together)
'combined_languages' => [
    'persian',
    'arabic',
    'urdu',
    'hindi',
    'bengali',
    'gujarati',
    'thai',
    'khmer',
    'lao',
    'myanmar',
],

// Built-in mappings (complete for all 10 languages)
'mappings' => [
    'persian' => ['۰' => '0', '۱' => '1', '۲' => '2', /* ... */],
    'arabic'  => ['٠' => '0', '١' => '1', '٢' => '2', /* ... */],
    'urdu'    => ['۰' => '0', '۱' => '1', '۲' => '2', /* ... */],
    'hindi'   => ['०' => '0', '१' => '1', '२' => '2', /* ... */],
    'bengali' => ['০' => '0', '১' => '1', '২' => '2', /* ... */],
    'gujarati'=> ['૦' => '0', '૧' => '1', '૨' => '2', /* ... */],
    'thai'    => ['๐' => '0', '๑' => '1', '๒' => '2', /* ... */],
    'khmer'   => ['០' => '0', '១' => '1', '២' => '2', /* ... */],
    'lao'     => ['໐' => '0', '໑' => '1', '໒' => '2', /* ... */],
    'myanmar' => ['၀' => '0', '၁' => '1', '၂' => '2', /* ... */],
],

// Custom languages (add your own)
'custom_mappings' => [
    // 'tamil' => ['௦' => '0', '௧' => '1', /* ... */],
],

// Excluded routes (not normalized)
'except' => [
    'api/webhook',
    'admin/*',
],
```

🚀 Adding a New Language
-----------------------

[](#-adding-a-new-language)

To add a new language:

1. Define the mapping in `custom_mappings`:

```
'custom_mappings' => [
    'tamil' => [
        '௦' => '0', '௧' => '1', '௨' => '2', '௩' => '3',
        '௪' => '4', '௫' => '5', '௬' => '6', '௭' => '7',
        '௮' => '8', '௯' => '9',
    ],
],
```

2. Add the language name to `combined_languages`:

```
'combined_languages' => [
    'persian', 'arabic', 'tamil', // Add your new language
],
```

🛠️ Middleware
-------------

[](#️-middleware)

By default, middleware is **automatically** added to all requests (`auto_middleware => true`).

To disable auto-registration and register manually:

```
// config/number-normalizer.php
'auto_middleware' => false,
```

Then in `app/Http/Kernel.php`:

```
protected $middleware = [
    // ...
    \NumberNormalizer\Http\Middleware\NormalizeNumbers::class,
];
```

Or apply only to specific routes:

```
Route::post('/register', ...)->middleware('normalize.numbers');
```

💻 Manual Usage
--------------

[](#-manual-usage)

```
use NumberNormalizer\Facades\NumberNormalizer;

// Convert all supported languages
NumberNormalizer::toEnglish('قیمت: ۱۲۳۴ و ๑๒๓'); // قیمت: 1234 و 123

// Specific languages only
NumberNormalizer::toEnglish('۱۲۳ و ١٢٣', ['persian', 'arabic']);

// Custom mapping
NumberNormalizer::withMapping('۱۲۳', ['۱' => '1', '۲' => '2', '۳' => '3']);
```

🎯 Use Cases
-----------

[](#-use-cases)

- 🌐 **Multi-language applications** - Normalize numbers from users worldwide
- 📱 **International forms** - Phone numbers, national IDs, amounts
- 💰 **E-commerce** - Currency amounts from different regions
- 🏦 **Financial systems** - Standardize numerical inputs
- 📊 **Data processing** - Clean and normalize data from various sources

📊 Language Coverage by Region
-----------------------------

[](#-language-coverage-by-region)

RegionLanguages**Middle East**Persian, Arabic, Urdu**South Asia**Hindi, Bengali, Gujarati**Southeast Asia**Thai, Khmer, Lao, Myanmar**Europe**Spanish📝 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

⭐ Support
---------

[](#-support)

If you find this package helpful, please give it a ⭐ on [GitHub](https://github.com/DevHamidShahbazi/number-normalizer)!

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6bdc0da39a2ce4d7311d99838affdcfbacb695d8b07ee87ebac95731ceac1bc0?d=identicon)[DevHamidShahbazi](/maintainers/DevHamidShahbazi)

---

Top Contributors

[![DevHamidShahbazi](https://avatars.githubusercontent.com/u/92720330?v=4)](https://github.com/DevHamidShahbazi "DevHamidShahbazi (9 commits)")

### Embed Badge

![Health badge](/badges/devhamidshahbazi-number-normalizer/health.svg)

```
[![Health](https://phpackages.com/badges/devhamidshahbazi-number-normalizer/health.svg)](https://phpackages.com/packages/devhamidshahbazi-number-normalizer)
```

###  Alternatives

[illuminate/pagination

The Illuminate Pagination package.

12234.6M1.1k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9350.2M308](/packages/illuminate-pipeline)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.4M234](/packages/illuminate-broadcasting)[illuminate/redis

The Illuminate Redis package.

8314.8M407](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.7M144](/packages/illuminate-cookie)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
