Normalize Persian Digits
Persian keyboards commonly type ۰-۹ (or Arabic-Indic ٠-٩) instead of 0-9. This utility converts either set back to plain digits, so numeric inputs and parsers keep working regardless of which keyboard the user is on. Price Input uses it internally.
Last updated August 9, 2026
Overview
Type Persian or Arabic-Indic digits above; the normalized result updates below as you type.
12345
"use client"
import * as React from "react"
import { Input } from "@/components/ui/input"
import { normalizePersianDigits } from "@/lib/normalize-persian-digits"
export function NormalizePersianDigitsDemoExample() {
const [raw, setRaw] = React.useState("۱۲۳۴۵")
return (
<div className="flex w-full max-w-xs flex-col gap-3">
<Input
dir="ltr"
value={raw}
onChange={(event) => setRaw(event.target.value)}
placeholder="۰۱۲۳..."
/>
<div className="rounded-lg border border-border px-3 py-2 font-mono text-sm">
{normalizePersianDigits(raw) || " "}
</div>
</div>
)
}Installation
$ npx shadcn@latest add https://ui.persian-labs.ir/r/normalize-persian-digits.jsonUsage
import { normalizePersianDigits } from "@/lib/normalize-persian-digits"
normalizePersianDigits("۱۲۳۴۵") // "12345"
normalizePersianDigits("قیمت ٤٥٠") // "قیمت 450"