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

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

alirezasedghi/virastar
======================

Virastar is a Persian text cleaner.

v1.0.2(4y ago)1977MITPHPPHP &gt;=7.0.0

Since Mar 22Pushed 4y ago2 watchersCompare

[ Source](https://github.com/AlirezaSedghi/Virastar)[ Packagist](https://packagist.org/packages/alirezasedghi/virastar)[ RSS](/packages/alirezasedghi-virastar/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

 [![کتابخانه ویراستاری متن فارسی برای PHP](https://camo.githubusercontent.com/6b5e8752c3d9f203132253e0585aa542396c311c46c28c4c637df2456773a37b/68747470733a2f2f6769746875622e616c6972657a617365646768692e636f6d2f76697261737461722f6173736574732f696d616765732f6c6f676f2f66617669636f6e2e706e67)](https://camo.githubusercontent.com/6b5e8752c3d9f203132253e0585aa542396c311c46c28c4c637df2456773a37b/68747470733a2f2f6769746875622e616c6972657a617365646768692e636f6d2f76697261737461722f6173736574732f696d616765732f6c6f676f2f66617669636f6e2e706e67)
 Virastar
ویراستار
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

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

 Virastar is a Persian text cleaner.
 کتابخانه ویراستاری متن فارسی برای PHP

 ![Required PHP Version](https://camo.githubusercontent.com/0b518bcf75e642f238252deff88efc05ac3f848d62ad28dcd1fbdbb6d8430262/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e302e302d626c75653f7374796c653d666c61742d737175617265) [![Total Downloads](https://camo.githubusercontent.com/f1710ad699f4d1c90df1ad3ce3ef3d03642605a5d7a88d0c0db0977e1fe8682d/68747470733a2f2f706f7365722e707567782e6f72672f616c6972657a617365646768692f76697261737461722f646f776e6c6f6164733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alirezasedghi/virastar) [![Latest Stable Version](https://camo.githubusercontent.com/fb78f551fc6596f893024fe7e75faf9a77208495dff5a41185b8febee94f9649/68747470733a2f2f706f7365722e707567782e6f72672f616c6972657a617365646768692f76697261737461722f762f737461626c653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alirezasedghi/virastar) [![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://raw.githubusercontent.com/AlirezaSedghi/Virastar/master/LICENSE) [![GitHub issues](https://camo.githubusercontent.com/d4dafc519049fd9d4c5d4ba03b518350da2eea9029c655d1be544d958f048bb5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f416c6972657a615365646768692f56697261737461722e7376673f7374796c653d666c61742d737175617265)](https://github.com/AlirezaSedghi/Virastar/issues)

> This repository is PHP port of [brothersincode/virastar](https://github.com/brothersincode/virastar)

Official website and [Persian usage guide](https://github.alirezasedghi.com/virastar/#documents)

Install
-------

[](#install)

```
composer require alirezasedghi/virastar
```

Usage
-----

[](#usage)

```
// Require Composer's autoloader.
require 'vendor/autoload.php';

// Using Virastar namespace.
use Alirezasedghi\Virastar\Virastar;

$virastar   = new Virastar();
$text       = "فارسي را كمی درست تر می نويسيم";
$cleaned    = $virastar->cleanup($text);

echo $cleaned; // Outputs: "فارسی را کمی درست‌تر می‌نویسیم"
```

#### Virastar(\[options\])

[](#virastaroptions)

##### options

[](#options)

Type: `array`

```
$virastar   = new Virastar([
        "fix_english_numbers": false,
        "cleanup_line_breaks": false
    ]);
```

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

[](#options-and-specifications)

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

#### `normalize_eol`

[](#normalize_eol)

*default*: `true`

- replace windows end of lines with unix eol (`\n`)

#### `decode_html_entities`

[](#decode_html_entities)

*default*: `true`

- converts numeral and selected html character-sets into original characters

#### `fix_dashes`

[](#fix_dashes)

*default*: `true`

- replaces triple dash to mdash
- replaces double dash to ndash

#### `fix_three_dots`

[](#fix_three_dots)

*default*: `true`

- removes spaces between dots
- replaces three dots with ellipsis character

#### `normalize_ellipsis`

[](#normalize_ellipsis)

*default*: `true`

- replaces more than one ellipsis with one
- replaces (space|tab|zwnj) after ellipsis with one space

#### `normalize_dates`

[](#normalize_dates)

*default*: `true`

- re-orders date parts with slash as delimiter

#### `fix_english_quotes_pairs`

[](#fix_english_quotes_pairs)

*default*: `true`

- replaces english quote pairs (`“”`) with their persian equivalent (`«»`)

#### `fix_english_quotes`

[](#fix_english_quotes)

*default*: `true`

- replaces english quote marks with their persian equivalent

#### `fix_hamzeh`

[](#fix_hamzeh)

*default*: `true`

- replaces `ه` followed by (space|ZWNJ|lrm) follow by `ی` with `هٔ`
- replaces `ه` followed by (space|ZWNJ|lrm|nothing) follow by `ء` with `هٔ`
- replaces `هٓ` or single-character `ۀ` with the standard `هٔ`

#### `fix_hamzeh_arabic`

[](#fix_hamzeh_arabic)

*default*: `false`

- converts arabic hamzeh `ة` to `هٔ`

#### `cleanup_rlm`

[](#cleanup_rlm)

*default*: `true`

- converts Right-to-left marks followed by persian characters to zero-width non-joiners (ZWNJ)

#### `cleanup_zwnj`

[](#cleanup_zwnj)

*default*: `true`

- converts all soft hyphens (`&shy;`) into zwnj
- removes more than one zwnj
- cleans zwnj after characters that don't connect to the next
- cleans zwnj before and after numbers, english words, spaces and punctuations
- removes unnecessary zwnj on start/end of each line

#### `fix_arabic_numbers`

[](#fix_arabic_numbers)

*default*: `true`

- replaces arabic numbers with their persian equivalent

#### `fix_english_numbers`

[](#fix_english_numbers)

*default*: `true`

- replaces english numbers with their persian equivalent

#### `fix_numeral_symbols`

[](#fix_numeral_symbols)

*default*: `true`

- replaces english percent signs (U+066A)
- replaces dots between numbers into decimal separator (U+066B)
- replaces commas between numbers into thousands separator (U+066C)

#### `fix_misc_non_persian_chars`

[](#fix_misc_non_persian_chars)

*default*: `true`

- replaces arabic normal/swash kaf with its persian equivalent
- replaces arabic/urdu/pushtu/uyghur yeh with its persian equivalent
- replaces kurdish he with its persian equivalent

#### `fix_punctuations`

[](#fix_punctuations)

*default*: `true`

- replaces `,`, `;` with its persian equivalent

#### `fix_question_mark`

[](#fix_question_mark)

*default*: `true`

- replaces question marks with its persian equivalent

#### `fix_prefix_spacing`

[](#fix_prefix_spacing)

*default*: `true`

- puts zwnj between the word and the prefix:
    - `mi*`, `nemi*`, `bi*`

#### `fix_suffix_spacing`

[](#fix_suffix_spacing)

*default*: `true`

- puts zwnj between the word and the suffix:
    - `*ha`, `*haye`
    - `*am`, `*at`, `*ash`, `*ei`, `*eid`, `*eem`, `*and`, `*man`, `*tan`, `*shan`
    - `*tar`, `*tari`, `*tarin`
    - `*hayee`, `*hayam`, `*hayat`, `*hayash`, `*hayetan`, `*hayeman`, `*hayeshan`

#### `fix_suffix_misc`

[](#fix_suffix_misc)

*default*: `true`

- replaces `ه` followed by `ئ` or `ی`, and then by `ی`, with `ه‌ای`

#### `fix_spacing_for_braces_and_quotes`

[](#fix_spacing_for_braces_and_quotes)

*default*: `true`

- removes inside spaces and more than one outside for `()`, `[]`, `{}`, `“”` and `«»`

#### `fix_spacing_for_punctuations`

[](#fix_spacing_for_punctuations)

*default*: `true`

- removes space before punctuations
- removes more than one space after punctuations, except followed by new-lines
- removes space after colon that separates time parts
- removes space after dots in numbers
- removes space before some common domain tlds
- removes space between question and exclamation marks
- removes space between same marks

#### `fix_diacritics`

[](#fix_diacritics)

*default*: `true`

- cleans zwnj before diacritic characters
- cleans more than one diacritic characters
- clean spaces before diacritic characters

### `remove_diacritics`

[](#remove_diacritics)

*default*: `false`

- removes all diacritic characters

#### `fix_persian_glyphs`

[](#fix_persian_glyphs)

*default*: `true`

- converts incorrect persian glyphs to standard characters

#### `fix_misc_spacing`

[](#fix_misc_spacing)

*default*: `true`

- removes space before parentheses on misc cases
- removes space before braces containing numbers

#### `cleanup_spacing`

[](#cleanup_spacing)

*default*: `true`

- replaces more than one space with just a single one
- cleans whitespace/zwnj between new-lines

#### `cleanup_line_breaks`

[](#cleanup_line_breaks)

*default*: `true`

- cleans more than **two** contiguous line breaks

#### `cleanup_begin_and_end`

[](#cleanup_begin_and_end)

*default*: `true`

- removes space/tab/zwnj/nbsp from the beginning of the new-lines
- remove spaces, tabs, zwnj, direction marks and new lines from the beginning and end of text

### markdown

[](#markdown)

#### `markdown_normalize_braces`

[](#markdown_normalize_braces)

*default*: `true`

- remove spaces between `[]` and `()` (`[text] (link)` into `[text](link)`)
- removes space between `!` and opening brace (`! [alt](src)` into `![alt](src)`)
- remove spaces inside double `()`, `[]`, `{}` (`[[ text ]]` into `[[text]]`)
- remove spaces between double `()`, `[]`, `{}` (`[[text] ]` into `[[text]]`)

#### `markdown_normalize_lists`

[](#markdown_normalize_lists)

*default*: `true`

- removes extra lines between two items on a markdown list beginning with `-`, `*` or `#`

#### `skip_markdown_ordered_lists_numbers_conversion`

[](#skip_markdown_ordered_lists_numbers_conversion)

*default*: `false`

- skips converting english numbers of ordered lists in markdown

### aggressive editing

[](#aggressive-editing)

#### `cleanup_extra_marks`

[](#cleanup_extra_marks)

*default*: `true`

- replaces more than one exclamation mark with just one
- replaces more than one english or persian question mark with just one
- re-orders consecutive marks: `?!` into `!?`

#### `kashidas_as_parenthetic`

[](#kashidas_as_parenthetic)

*default*: `true`

- replaces kashidas to ndash in parenthetic

#### `cleanup_kashidas`

[](#cleanup_kashidas)

*default*: `true`

- converts kashida between numbers to ndash
- removes all kashidas between non-whitespace characters

### extras

[](#extras)

#### `preserve_front_matter`

[](#preserve_front_matter)

*default*: `true`

- preserves front matter data in the text

#### `preserve_HTML`

[](#preserve_html)

*default*: `true`

- preserves all html tags in the text

#### `preserve_comments`

[](#preserve_comments)

*default*: `true`

- preserves all html comments in the text

#### `preserve_entities`

[](#preserve_entities)

*default*: `true`

- preserves all html entities in the text

#### `preserve_URIs`

[](#preserve_uris)

*default*: `true`

- preserves all uri strings in the text

#### `preserve_brackets`

[](#preserve_brackets)

*default*: `false`

- preserves strings inside square brackets (`[]`)

#### `preserve_braces`

[](#preserve_braces)

*default*: `false`

- preserves strings inside curly braces (`{}`)

#### `preserve_nbsp`

[](#preserve_nbsp)

*default*: `true`

- preserves all no-break space entities in the text

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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 ~1 days

Total

3

Last Release

1508d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/776d857905afc82f582e4d843ae3e26821e37bc7c586a2e2d1c24aa86b6ece5a?d=identicon)[AlirezaSedghi](/maintainers/AlirezaSedghi)

---

Top Contributors

[![AlirezaSedghi](https://avatars.githubusercontent.com/u/8061051?v=4)](https://github.com/AlirezaSedghi "AlirezaSedghi (15 commits)")

---

Tags

cleanerfarsinormalizerpersianpersian-nlpphppersianفارسیvirastarText Cleanerویراستارویرایشگر

### Embed Badge

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

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

###  Alternatives

[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)[pishran/laravel-persian-string

Convert Arabic/English/etc numbers and characters to Persian numbers and characters in Laravel models.

206.7k](/packages/pishran-laravel-persian-string)[aloko/nova-persian-datepicker

Persian Datepicker for Laravel Nova.

203.5k](/packages/aloko-nova-persian-datepicker)[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)
