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

persian-address-parser

v0.1.0

Published

Parse free-form Persian addresses into structured fields — province, city, street, alley, plaque, unit and floor.

Readme

persian-address-parser

Parse free-form Persian addresses into structured data.

Persian addresses are written as one long line of prose, with no fixed order and no fixed spelling. This library turns that line into named fields.

import { parseAddress } from 'persian-address-parser';

parseAddress('فارس شیراز خیابان زند کوچه لاله پلاک ۱۲ واحد ۳ طبقه ۲');
{
  province: 'فارس',
  city:     'شیراز',
  street:   'زند',
  alley:    'لاله',
  number:   '12',
  unit:     '3',
  floor:    '2',
  extra:    undefined
}

Install

npm install persian-address-parser

Zero runtime dependencies. Ships ESM and CJS builds with TypeScript types.

API

parseAddress(input: string): ParsedAddress

| Field | Type | Description | |---|---|---| | province | string \| undefined | Matched against the official list of 31 provinces. Inferred from the city when not written. | | city | string \| undefined | Matched against the official city list, returned in its canonical spelling. | | street | string \| undefined | Name after خیابان / خیابون / بلوار / خ / بل | | alley | string \| undefined | Name after کوچه / کوی / بن‌بست / ک | | number | string \| undefined | Plaque number. A string, because 12/1 and 12-3 are valid. | | unit | string \| undefined | Number after واحد | | floor | string \| undefined | Number after طبقه / ط | | extra | string \| undefined | Everything that was recognised as none of the above. |

Fields that are not present in the input are undefined.

What it handles

Mixed numerals. Persian ۱۲, Arabic ١٢ and Latin 12 are all normalised before parsing.

Arabic characters. ي and ك are folded to ی and ک, and hamza forms are folded when matching place names — so نایین matches نائین in the reference data.

Spacing variants. ZWNJ, missing spaces and extra spaces are ignored when matching place names, so ولی‌عصر, ولی عصر and ولیعصر are treated as the same name.

Abbreviations. خ, ک, پ, ط, بل, and their variants with dots, colons and dashes.

Missing separators. Commas are optional. Keywords themselves act as boundaries, so تهران خیابان بهشتی پلاک ۵ parses the same as the comma-separated form.

Diacritics. Harakat and invisible direction marks are stripped.

Province inference. If the input names only a city, the province is filled in from the reference data.

Limitations

  • Villages and districts are not supported. The reference data covers provinces and cities only. Anything else lands in extra.
  • Landmarks are not a field yet. نبش کارگر, جنب داروخانه, بالاتر از پارک وی are left in extra.
  • Postal codes are not extracted. They are left in place.
  • No fuzzy matching yet. A misspelled city name that is not covered by the character-folding rules will not match. Levenshtein-based matching is planned.
  • Ambiguous city names resolve to a single entry. Where two provinces contain a city with the same name, one of them wins.

Accuracy

Measured against the 200 labelled addresses in tests/fixtures/addresses.json:

| Field | | |---|---| | number | 100% | | unit | 100% | | floor | 100% | | province | 98% | | alley | 94% | | city | 81% | | street | 78% |

Most of that fixture set is synthetic and deliberately messy, but it is still cleaner than real user input, so treat these as an upper bound rather than a promise. Contributions of real addresses are welcome — see below.

Contributing

One of the useful contribution is data. If the parser gets an address wrong, add it to tests/fixtures/addresses.json with the expected output and open a pull request. Please do not submit anyone's home address.

git clone https://github.com/rezadev8/persian-address-parser
npm install
npm test

npm run accuracy reports per-field accuracy across the whole fixture set.

License

MIT