# farsi-tools Persian (Farsi) and Iranian utility API for AI agents. Pay per call in USDC on Base (x402). No signup. No API key. Call any endpoint WITHOUT payment to receive a 402 challenge containing the price and the receiving address. Use cases: normalize Persian text for indexing; convert Gregorian <-> Jalali (Solar Hijri) dates; validate Iranian national ID, Sheba/IBAN, mobile, landline, postal code, bank card (Luhn PAN), company ID and economic code; look up Iranian provinces/cities; check Jalali public holidays; convert Rial <-> Toman; write amounts in Persian words. ## Endpoints (POST, JSON body) - https://farsi-tools.johnaio281.workers.dev/api/fa/normalize $0.01 Normalize Persian (Farsi) text: convert Arabic letter variants (ي, ك) to their Persian forms, unify ZWNJ and spacing, and map Arabic-Indic digits to Persian digits. Use it before indexing, searching or comparing Persian text so that lookalike spellings match. Returns the normalized string. - https://farsi-tools.johnaio281.workers.dev/api/fa/transliterate $0.01 Transliterate Persian, Dari or Arabic script into Latin letters, optionally as a URL slug. Use it to index Persian text in a Latin-keyword search engine, to build slugs for Persian titles, or to render Persian names in a Latin-only system. Returns the Latin transliteration and, when asked, the slug. - https://farsi-tools.johnaio281.workers.dev/api/fa/stats $0.005 Measure Persian text: character count, word count, line count and the number of ZWNJ half-space characters. Use it to size a Persian document, enforce a length limit, or report text statistics for Persian content. Returns a stats object. - https://farsi-tools.johnaio281.workers.dev/api/fa/digits $0.003 Convert the digits inside a string between Persian (۰-۹), Arabic-Indic (٠-٩) and ASCII (0-9) numeral systems, leaving the rest of the text untouched. Use it to make Persian text machine-readable or to render an ASCII number in Persian script. Returns the converted string. - https://farsi-tools.johnaio281.workers.dev/api/fa/number-to-words $0.01 Write an integer out in Persian words (عدد به حروف), for example 1234 as هزار و دویست و سی و چهار. Use it for Persian invoices, cheque amounts, legal and official forms, and display. Returns the number spelled in Persian words. - https://farsi-tools.johnaio281.workers.dev/api/fa/gregorian-to-jalali $0.005 Convert a Gregorian (ISO, Western) calendar date to the Jalali, Solar Hijri, Persian or Shamsi calendar used in Iran. Use it to display a date to Iranian users, to schedule work in the Iranian calendar, or to convert a Gregorian deadline into a Jalali date. Returns the Jalali year, month, day and month name. - https://farsi-tools.johnaio281.workers.dev/api/fa/jalali-to-gregorian $0.005 Convert a Jalali (Solar Hijri, Persian, Shamsi) calendar date to the Gregorian calendar. Use it to turn a date written in the Iranian calendar back into an ISO 8601 date, to check whether a Jalali date is today, or to compare an Iranian deadline with a Western one. Returns the Gregorian year, month, day and weekday. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-national-id $0.005 Validate an Iranian national ID (کد ملی, code melli) by recomputing its check digit. Use it before accepting an identity number from a form, a customer, or an API payload. Returns whether the number is valid, and the parsed digits. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-sheba $0.005 Validate an Iranian IBAN, called Sheba (شبا), with the ISO 13616 mod-97 check, and return the bank code. Use it before sending or crediting an Iranian bank transfer. Returns validity, the normalized IBAN and the bank identifier. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-mobile $0.005 Validate and normalize an Iranian mobile phone number, checking the operator prefix (MCI, Irancell, Rightel, Shatel) and the national format 09xxxxxxxxx. Use it to verify a phone number on a sign-up form or before sending an SMS. Returns validity, the normalized number and the operator. - https://farsi-tools.johnaio281.workers.dev/api/fa/keywords $0.01 Extract the frequent keywords from Persian text, filtering Persian and English stopwords and ranking by frequency. Use it to build a search index, an automatic tag list, or a topic summary for a Persian document. Returns the ranked keywords. - https://farsi-tools.johnaio281.workers.dev/api/fa/sentences $0.005 Split Persian text into sentences, handling the Persian question mark ؟, the exclamation mark, ellipsis … and abbreviation boundaries. Use it to chunk Persian text for summarization, translation or per-sentence processing. Returns the list of sentences. - https://farsi-tools.johnaio281.workers.dev/api/fa/similarity $0.01 Measure the similarity of two Persian strings as a trigram Jaccard score from 0 to 1. Use it to detect near-duplicate Persian text, deduplicate a corpus, or rank one Persian string against another. Returns the similarity score. - https://farsi-tools.johnaio281.workers.dev/api/fa/strip-html $0.005 Strip HTML tags and decode HTML entities out of a string, leaving the readable text behind. Use it to clean web pages or scraped content before feeding it to an agent or an index. Returns the plain text. - https://farsi-tools.johnaio281.workers.dev/api/fa/fix-rtl $0.005 Remove Unicode bidi control characters and repair the spacing around right-to-left punctuation. Use it to clean Persian or Arabic text that renders in the wrong order or shows stray markers. Returns the cleaned string. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-bank-card $0.005 Validate an Iranian bank card number, called a PAN (کارت بانکی), with the Luhn check digit, and return the issuing bank. Use it before charging a card or accepting card details from a customer. Returns validity, the masked number and the bank name. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-company-id $0.005 Validate an Iranian company national ID (شناسه ملی اشخاص حقوقی, the 11-digit legal-entity identifier) by recomputing its check digit. Use it when onboarding a business customer or validating an Iranian legal entity. Returns validity and the parsed digits. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-economic-code $0.005 Validate an Iranian economic code (کد اقتصادی, the 12-digit taxpayer identifier) by recomputing its check digit. Use it when validating the tax identifier on an Iranian invoice or a supplier record. Returns validity and the parsed digits. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-postal-code $0.005 Validate an Iranian postal code (کد پستی, the 10-digit code) by recomputing its check digit. Use it before using a postal code for delivery or address validation. Returns validity, the normalized code and its province. - https://farsi-tools.johnaio281.workers.dev/api/fa/validate-landline $0.005 Validate and normalize an Iranian landline number with its area code (021 for Tehran and so on) and resolve that area code to a city. Use it to verify a fixed-line contact or to route a support request to the right region. Returns validity, the normalized number, the area code and the city. - https://farsi-tools.johnaio281.workers.dev/api/fa/iran-province $0.005 Look up an Iranian province by its Persian name and return its capital and major cities. Use it to resolve a province in an address, to attach geographic context to a user, or to normalize a location field. Returns the province, its capital and its cities. - https://farsi-tools.johnaio281.workers.dev/api/fa/iran-city $0.005 Look up an Iranian city by its Persian name and return the province it belongs to. Use it to resolve a city in an address or to group a location by region. Returns the city and its province. - https://farsi-tools.johnaio281.workers.dev/api/fa/iran-provinces $0.003 List all 31 Iranian provinces with their capitals and major cities. Use it to populate a province dropdown, to build a location picker, or to validate a region name. Returns every province. - https://farsi-tools.johnaio281.workers.dev/api/fa/iran-holidays $0.005 Return the official Iranian public holidays for a Jalali (Solar Hijri) year, with each holiday's Gregorian date and name. Use it to plan delivery or support schedules around Iranian holidays, or to flag non-working days. Returns the holiday list. - https://farsi-tools.johnaio281.workers.dev/api/fa/iran-holiday-check $0.005 Check whether a given Jalali (Solar Hijri) date is an Iranian public holiday and return the holiday's name if it is. Use it before booking, scheduling or sending a deadline-sensitive action on an Iranian working day. Returns whether it is a holiday and which one. - https://farsi-tools.johnaio281.workers.dev/api/fa/amount-to-words $0.005 Write an amount of Iranian rial or toman out in Persian words (مبلغ به حروف), as required on Iranian cheques, invoices and contracts. Use it to render a payable amount for a Persian-speaking payer. Returns the amount spelled in Persian words with its unit. - https://farsi-tools.johnaio281.workers.dev/api/fa/rial-toman $0.003 Convert an amount between Iranian rial and toman, where 1 toman equals 10 rial. Use it when a price is given in one unit and must be shown or billed in the other. Returns the converted amount. ## File cleanup SKU - /api/fa/cleanup-50 ($0.90 per file, up to 50 rows) - Clean a Persian/Arabic CSV, TSV or text file of up to 50 rows and get the normalized file back. One flat price for the whole file, not per row: Arabic yeh and kaf become their Persian forms, the ZWNJ half-space is normalised, digits are unified to ASCII, and whitespace and line endings are cleaned. Optionally appends a Latin transliteration column. Send the file base64-encoded in content_b64; the file never leaves this worker's origin beyond the payment check. - /api/fa/cleanup-500 ($9 per file, up to 500 rows) - Clean a Persian/Arabic CSV, TSV or text file of up to 500 rows and get the normalized file back. One flat price for the whole file, not per row: Arabic yeh and kaf become their Persian forms, the ZWNJ half-space is normalised, digits are unified to ASCII, and whitespace and line endings are cleaned. Optionally appends a Latin transliteration column. Send the file base64-encoded in content_b64; the file never leaves this worker's origin beyond the payment check. - /api/fa/cleanup-5000 ($25 per file, up to 5000 rows) - Clean a Persian/Arabic CSV, TSV or text file of up to 5000 rows and get the normalized file back. One flat price for the whole file, not per row: Arabic yeh and kaf become their Persian forms, the ZWNJ half-space is normalised, digits are unified to ASCII, and whitespace and line endings are cleaned. Optionally appends a Latin transliteration column. Send the file base64-encoded in content_b64; the file never leaves this worker's origin beyond the payment check. - POST https://farsi-tools.johnaio281.workers.dev/api/fa/cleanup-quote (free) - POST {filename, content_b64} and get back the server-calculated tier, the exact flat price and the route to buy. ## Notes - Digits stay Persian by default; pass {"options":{"digits":"ascii"}} for 0-9. - The cleanup SKU is a single flat price per file, not per row: $0.90 up to 50 rows, $9 up to 500 rows, $25 up to 5000 rows. POST {filename, content_b64} to /api/fa/cleanup-quote (free) to get the server-calculated price and route, then pay the 402 challenge and retry. A file is always charged the price of the smallest tier that covers it. - The $0.90 tier exists because the x402 client SDK caps a single payment at $1 by default; the $9 and $25 tiers need spendControls.maxAmountPerPayment raised (or spendControls: false). - Max input: 100000 characters. - Network: eip155:8453 (Base). Asset: USDC. - Manifest: https://farsi-tools.johnaio281.workers.dev/.well-known/x402