Guide · Arabic & RTL

Arabic search that finds what people mean.

أحمد and احمد, مدرسة and مدرسه, ١٣ and 13: people type the same thing differently, and an exact match treats them as different words. One small normalising function, run on both sides, fixes most of it.

Updated 16 November 2026Sources checked 16 November 2026Reviewed by Eng. Hasan Kassas

The short answer

Arabic has several spellings that readers treat as the same word: alef with or without hamza (أ إ آ ا), alef maqsura or ya at the end (ى ي), ta marbuta or ha (ة ه), optional diacritics, the decorative stretch called tatweel (ـ), and two sets of digits. Keyboards add more: Persian layouts type ک and ی, and old text can contain presentation forms like ﻻ.

Normalise the stored text and the search query with the same function, then compare. For a marketplace like Dealio, the marketplace Innoveev built and runs, the listings and the searches are written by different people on different keyboards, which is exactly where this matters. Keep the original text for display; only search the normalised copy.

What gets folded

Rules, with an example each

BecomesExample
أ إ آ ٱ (alef with hamza or madda)اإبراهيم → ابراهيم
ى (alef maqsura)يمستشفى → مستشفي
ة (ta marbuta)همدرسة → مدرسه
ؤ and ئو and يمسؤول → مسوول
Diacritics (fatha, damma, kasra, shadda, sukun, tanwin)removedمُسْتَشْفى → مستشفي
Tatweel ـremovedسيـــارة → سياره
Presentation forms such as ﻻbase letters (NFKC)ﻻبتوب → لابتوب
Arabic-Indic ٠-٩ and Persian ۰-۹ digits0-9آيفون ١٣ → ايفون 13
Persian ک and یك and يکتاب → كتاب
Tested code · JavaScript

The normaliser and a tokenizer

normalizeArabic folds the spellings above. searchTokens splits the result into words and drops the article at the start of a word, so السيارة, بالسيارة and للبيع match سيارة and بيع:

// Normalise Arabic text so a search matches however the word was typed.
// Run the SAME function on stored text and on the query.
const DIACRITICS = /[ً-ٰٟۖ-ۭ]/g; // tashkeel, shadda, sukun, dagger alef
const toLatinDigits = (s) => s
  .replace(/[٠-٩]/g, (d) => d.charCodeAt(0) - 0x0660)  // Arabic-Indic
  .replace(/[۰-۹]/g, (d) => d.charCodeAt(0) - 0x06F0); // Extended (Persian keyboards)

function normalizeArabic(text) {
  return toLatinDigits(String(text).normalize("NFKC")) // ﻻ ﺍ presentation forms -> base letters
    .replace(DIACRITICS, "")
    .replace(/ـ/g, "")          // tatweel: سيـــارة
    .replace(/[أإآٱ]/g, "ا")
    .replace(/ى/g, "ي")
    .replace(/ة/g, "ه")
    .replace(/ؤ/g, "و")
    .replace(/ئ/g, "ي")
    .replace(/ک/g, "ك")
    .replace(/ی/g, "ي")
    .toLowerCase()
    .replace(/\s+/g, " ")
    .trim();
}

// Split into search tokens and drop the article: السيارة, بالسيارة, للبيع.
function searchTokens(text) {
  return normalizeArabic(text)
    .split(/[^\p{L}\p{N}]+/u)
    .filter(Boolean)
    .map((t) => t.replace(/^(?:[وفبك]?ال|لل)(?=\p{L}{2,})/u, ""));
}

16 test cases pass, including Latin text (lower-cased), extra spaces, a two-letter word that keeps its ال (الو), and ألمانيا, which loses "ال" too but still matches itself because both sides get the same treatment.

Tested code · Dart

The same rules inside a Flutter app

For offline search, normalise inside the app before writing to the local database, and normalise the query the same way. Dart has no built-in NFKC, so the lam-alef presentation forms are mapped by hand:

/// Normalise Arabic for offline search (same rules as the JavaScript version).
String normalizeArabic(String text) {
  var s = text;
  s = s.replaceAllMapped(RegExp('[٠-٩]'), (m) => '${m[0]!.codeUnitAt(0) - 0x0660}');
  s = s.replaceAllMapped(RegExp('[۰-۹]'), (m) => '${m[0]!.codeUnitAt(0) - 0x06F0}');
  s = s
      .replaceAll(RegExp('[ً-ٰٟۖ-ۭ]'), '')
      .replaceAll('ـ', '')
      .replaceAll('ﻻ', 'لا') // ﻻ lam-alef presentation form (Dart has no NFKC built in)
      .replaceAll('ﻼ', 'لا')
      .replaceAll(RegExp('[أإآٱ]'), 'ا')
      .replaceAll('ى', 'ي')
      .replaceAll('ة', 'ه')
      .replaceAll('ؤ', 'و')
      .replaceAll('ئ', 'ي')
      .replaceAll('ک', 'ك')
      .replaceAll('ی', 'ي');
  return s.toLowerCase().replaceAll(RegExp(r'\s+'), ' ').trim();
}

Run with flutter test against the same examples as the JavaScript version. Our offline-first guide explains why search should work without a connection.

Trade-offs

What this does not do

  • It is lossy on purpose. ة to ه merges words that differ only in that letter. That is fine for finding things and wrong for showing them, so never display the normalised text.
  • It is not a stemmer. كتاب and كتب stay different words. Full Arabic stemming brings its own errors; start with normalisation and add synonyms for the words your users actually search.
  • It does not transliterate. ايفون and iPhone are different strings. Keep a small synonym table for brand names your users type in both scripts.
  • Store the normalised copy in its own column and index that column. Normalising at query time on every row is slow on a phone and on a server.
  • Dialect spellings are a content problem, not a normalisation problem. If users search شو or ليش, add them to the synonym list rather than to the function.
FAQ

Common questions

Usually because the stored word and the query are spelled differently: hamza on the alef, ة or ه at the end, diacritics or tatweel, or Arabic-Indic digits. Normalise both with the same function before comparing.

Sources

Where these facts come from

  1. Arabic block chart (U+0600 to U+06FF)Unicode Consortium · accessed 16 Nov 2026
  2. UAX #15: Unicode Normalization FormsUnicode Consortium · accessed 16 Nov 2026
  3. String.prototype.normalize()MDN Web Docs · accessed 16 Nov 2026

Code tested with Node 24 and Flutter 3.44 on 16 November 2026.

Search that fails in Arabic?

Send us a few searches that should work and do not. We will tell you why.