Persian Slug

Converts Farsi/Persian (or mixed Persian+English) text into a URL-safe slug, e.g. for blog post or product URLs. By default, Persian characters are kept as-is rather than transliterated to Latin — percent-encoded Persian slugs are common and SEO-accepted on Iranian sites, and a forced transliteration produces awkward Latin approximations. Pass { transliterate: true } for a fully Latin/ASCII slug instead.

Last updated August 17, 2026

Overview

Type a Persian title above; the generated slug updates below as you type.

Installation

$ npx shadcn@latest add https://ui.persian-labs.ir/r/persian-slug.json

Usage

import { toPersianSlug, toLatinSlug } from "@/lib/persian-slug"
 
toPersianSlug("راهنمای خرید گوشی موبایل")
// "راهنمای-خرید-گوشی-موبایل"
 
toPersianSlug("بهترین لپ‌تاپ های Gaming 2024")
// "بهترین-لپتاپ-های-gaming-2024"
 
toLatinSlug("سلام دنیا")
// "slam-dnya"

Examples

Transliterate

Pass { transliterate: true } (or use toLatinSlug) to romanize Persian letters into a fully Latin/ASCII slug instead of keeping the Persian script.

RTL

Generated slugs read naturally alongside right-to-left Persian content, since the default mode keeps the Persian script rather than replacing it with Latin approximations.

API Reference

persian-slug

PersianSlugOptions