PHPackages                             octoberfa/virastar - 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. octoberfa/virastar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

octoberfa/virastar
==================

Virastar is a Persian text cleaner.

1.0.1(7y ago)451MITPHPPHP &gt;=7.1

Since Jan 7Pushed 7y ago2 watchersCompare

[ Source](https://github.com/octoberfa/virastar)[ Packagist](https://packagist.org/packages/octoberfa/virastar)[ RSS](/packages/octoberfa-virastar/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Virastar (ویراستار)
===================

[](#virastar-ویراستار)

Virastar is a Persian text cleaner.

[![Latest Stable Version](https://camo.githubusercontent.com/d375061829baa120ad8b764c3e5eca6f29c3758d9ec0473c244fa56f81efc232/68747470733a2f2f706f7365722e707567782e6f72672f6f63746f62657266612f76697261737461722f762f737461626c65)](https://packagist.org/packages/octoberfa/virastar)[![Latest Unstable Version](https://camo.githubusercontent.com/9b8ffa0a985572121233a097a62475212efcfadf78d4db1c1e115ea911160d8b/68747470733a2f2f706f7365722e707567782e6f72672f6f63746f62657266612f76697261737461722f762f756e737461626c65)](https://packagist.org/packages/octoberfa/virastar)[![Build Status](https://camo.githubusercontent.com/636d4b8d040583cbf6bd876e6031ffb2c0e71ceb9fda803b7cd017c4b3fec084/68747470733a2f2f7472617669732d63692e6f72672f6f63746f62657266612f76697261737461722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/octoberfa/virastar)[![Total Downloads](https://camo.githubusercontent.com/9df765cb67b87bec6baed04a4171a5cb086e8d2005e02cdd3ee2e0fb83d2b57b/68747470733a2f2f706f7365722e707567782e6f72672f6f63746f62657266612f76697261737461722f646f776e6c6f616473)](https://packagist.org/packages/octoberfa/virastar)[![License](https://camo.githubusercontent.com/a791f2d002e3b7c0b1012abc42862e7aafcb83cf696ad7d21d2b1f0387b862ef/68747470733a2f2f706f7365722e707567782e6f72672f6f63746f62657266612f76697261737461722f6c6963656e7365)](https://packagist.org/packages/octoberfa/virastar)[![composer.lock](https://camo.githubusercontent.com/4e40b8af82bb97c3296da750cdf1c58bb99399244cc463ad242cc0b3ebe8e956/68747470733a2f2f706f7365722e707567782e6f72672f6f63746f62657266612f76697261737461722f636f6d706f7365726c6f636b)](https://packagist.org/packages/octoberfa/virastar)

A php port of [juvee/virastar](https://github.com/juvee/virastar)

Install
-------

[](#install)

```
composer require octoberfa/virastar
```

Usage
-----

[](#usage)

```
require "./vendor/autoload.php";
echo virastar("فارسي را كمی درست تر می نويسيم");
// Outputs: "فارسی را کمی درست‌تر می‌نویسیم"
```

#### virastar(\[text\] \[,options\])

[](#virastartext-options)

##### text

[](#text)

Type: `string`

String of Persian source to be cleaned.

##### options

[](#options)

Type: `array`

```
virastar("سلام 123" ,["fix_english_numbers":false]);
// Outputs:"سلام 123"
```

Options and Specifications
--------------------------

[](#options-and-specifications)

Virastar comes with a list of options to control its behavior.

*all options are **enabled** by default.*

- `normalize_eol`

    - replace Windows end of lines with Unix EOL (`\n`)
- `decode_htmlentities`

    - converts all HTML characterSets into original characters
- `fix_dashes`

    - replace double dash to ndash and triple dash to mdash
- `fix_three_dots`

    - replace three dots with ellipsis
- `fix_english_quotes_pairs`

    - replace English quotes pairs (`“”`) with their Persian equivalent (`«»`)
- `fix_english_quotes`

    - replace English quotes, commas and semicolons with their Persian equivalent
- `fix_hamzeh`

    - convert `ه ی` to `هٔ`
- `cleanup_rlm`

    - converting Right-to-left marks followed by Persian characters to zero-width non-joiners (ZWNJ)
- `cleanup_zwnj`

    - remove more than one zwnj chars
    - remove unnecessary zwnj chars that are succeeded/preceded by a space
    - clean zwnj chars after Persian characters that don't conncet to the next letter
    - clean zwnj chars before English characters
    - clean zwnj chars after and before punctuation
- `fix_arabic_numbers`

    - replace Arabic numbers with their Persian equivalent
- `fix_english_numbers`

    - replace English numbers with their Persian equivalent
    - should not replace English numbers in English phrases
- `skip_markdown_ordered_lists_numbers_conversion`

    - skip converting English numbers of ordered lists in markdown
- `fix_misc_non_persian_chars`

    - replace Arabic kaf and Yeh with its Persian equivalent
- `fix_question_mark`

    - replace question marks with its Persian equivalent
- `fix_perfix_spacing`

    - put zwnj between word and prefix (`mi*` `nemi*`)
- `fix_suffix_spacing`

    - put zwnj between word and suffix (`*tar` `*tarin` `*ha` `*haye`)
- `fix_spacing_for_braces_and_quotes`

    - fix spacing for `()` `[]` `{}` `“”` `«»` (one space outside, no space inside)
    - correct `:;,.?!` spacing (one space after and no space before)
- `cleanup_spacing`

    - replace more than one space with just a single one
- `cleanup_begin_and_end`

    - remove spaces, tabs, and new lines from the beginning and end of text
- `cleanup_extra_marks`

    - replace more than one `!` or `?` mark with just one
- `kashidas_as_parenthetic`

    - replace kashidas to ndash in parenthetic
- `cleanup_kashidas`

    - remove all kashidas
- `preserve_HTML`

    - preserve all HTML tags
- `preserve_URIs`

    - preserve all URI links in the text
- `preserve_brackets`

    - preserve strings inside square brackets (`[]`)
- `preserve_braces`

    - preserve strings inside curly braces (`{}`)
- `preserve_code`

    - preserve strings inside html code tag and markdown "```"
- `preserve_pre`

    - preserve strings inside html pre tag

License
-------

[](#license)

This software is licensed under the MIT License. [View the license](LICENSE).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Every ~0 days

Total

2

Last Release

2685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fcfecbf3dfd14a9194e8dce3b7df733ff479f0831bfe05cabb010fc9f60951e1?d=identicon)[sajjad-ser](/maintainers/sajjad-ser)

---

Top Contributors

[![TheServat](https://avatars.githubusercontent.com/u/12908537?v=4)](https://github.com/TheServat "TheServat (5 commits)")

---

Tags

persianpersian-nlpvirastarnormalizeiranpersianfarsivirastar

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/octoberfa-virastar/health.svg)

```
[![Health](https://phpackages.com/badges/octoberfa-virastar/health.svg)](https://phpackages.com/packages/octoberfa-virastar)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

36473.2k8](/packages/fisharebest-ext-calendar)[opilo/farsi

Farsi Tools for Dates and Numbers and Strings (with Laravel Validation Support)

333.2k1](/packages/opilo-farsi)[iamfarhad/validation

🇮🇷 Complete Laravel Persian validation package - Iranian national ID, mobile numbers, Shamsi dates, IBAN/Sheba, postal codes &amp; more. Modern Laravel 10-12 support with both ValidationRule objects &amp; string-based rules.

2917.3k](/packages/iamfarhad-validation)[symfony_persia/symfonyjdate

Jalali (Shamsi) DateTime for Symfony2, Supports year higher than 2038

1010.6k](/packages/symfony-persia-symfonyjdate)

PHPackages © 2026

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