forked from persian-tools/go-persian-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
CLI
Amir Iranmanesh edited this page Aug 11, 2026
·
1 revision
One binary over every package. Text comes from the arguments, or from standard input when there are none, so it works both as a one-off and as a filter.
go install github.com/amiranmanesh/go-persian-tools/cmd/persian-tools@latestOr without installing anything:
docker run --rm ghcr.io/amiranmanesh/go-persian-tools:latest normalize "علي كريم"
echo "1402" | docker run --rm -i ghcr.io/amiranmanesh/go-persian-tools:latest to-persianText
| Command | Does |
|---|---|
normalize |
fold text for comparison, sorting and indexing |
fix-arabic |
replace Arabic characters with their Persian equivalents |
alpha |
keep only Persian script |
key-to-persian |
re-read text typed on an English keyboard layout |
key-to-english |
re-read text typed on a Persian keyboard layout |
finglish |
romanize Persian text |
reverse |
reverse the text by runes |
is-english |
report whether the text is only ASCII letters |
Digits and money
| Command | Does |
|---|---|
to-persian |
convert ASCII digits to Persian digits |
to-english |
convert Persian and Arabic-Indic digits to ASCII |
digits -set en|fa|all |
keep only digits |
currency -unit toman|rial|none |
group an amount in threes |
commas |
group an amount with ASCII commas |
words |
spell an amount out in Persian words |
Validators
| Command | Does |
|---|---|
national-id |
validate a national number |
national-id-place |
resolve its city and province |
card |
resolve the bank that issued a card number |
sheba |
resolve the bank of a Sheba code |
phone |
report whether a mobile number is valid |
phone-operator |
resolve its operator |
persian-tools normalize "علي كريم" # علی کریم
persian-tools words 156789 # صد و پنجاه و شش هزار و هفتصد و هشتاد و نه
persian-tools currency -unit toman 1234567 # ۱،۲۳۴،۵۶۷ تومان
persian-tools key-to-persian sghl # سلام
persian-tools sheba IR820540102680020817909002
persian-tools phone-operator 09123456789 # MCI
cat names.txt | persian-tools normalize > keys.txt| Code | Meaning |
|---|---|
| 0 | success (for a predicate: true) |
| 1 | a predicate answered false, or an I/O error |
| 2 | usage error: unknown command or bad flag |
Predicates (is-english, national-id, phone) exit non-zero on false, so a
shell can branch on them:
if persian-tools national-id "$code" >/dev/null; then
echo "valid"
fiRun persian-tools <command> -h for a command's flags, and
persian-tools --version for the build version.
Packages
Project