Arabic and Hebrew RTL Number Formatting with Intl
Understand how numbers are formatted in right-to-left (RTL) locales like Arabic and Hebrew. Learn about Eastern Arabic numerals, bidirectional text handling, and RTL-specific formatting rules.
Detailed Explanation
RTL Number Formatting: Arabic and Hebrew
Right-to-left locales present unique challenges for number formatting. While Arabic text reads right-to-left, numbers can read left-to-right or use Eastern Arabic digits. Hebrew uses standard Western digits but with RTL text context.
Eastern Arabic Numerals
Arabic locales may use Eastern Arabic-Indic digits:
new Intl.NumberFormat('ar-SA').format(1234567.89);
// "١٬٢٣٤٬٥٦٧٫٨٩"
new Intl.NumberFormat('ar-EG').format(1234567.89);
// "١٬٢٣٤٬٥٦٧٫٨٩"
The digit mapping:
| Western | Eastern Arabic |
|---|---|
| 0 | ٠ |
| 1 | ١ |
| 2 | ٢ |
| 3 | ٣ |
| 4 | ٤ |
| 5 | ٥ |
| 6 | ٦ |
| 7 | ٧ |
| 8 | ٨ |
| 9 | ٩ |
Arabic Currency Formatting
new Intl.NumberFormat('ar-SA', {
style: 'currency',
currency: 'SAR',
}).format(1234.5);
// "١٬٢٣٤٫٥٠ ر.س."
new Intl.NumberFormat('ar-SA', {
style: 'currency',
currency: 'USD',
}).format(1234.5);
// "١٬٢سش٫٥٠ US$"
Hebrew Formatting
Hebrew uses standard Western digits but places text elements (currency symbols, unit labels) according to RTL rules:
new Intl.NumberFormat('he-IL').format(1234567.89);
// "1,234,567.89"
new Intl.NumberFormat('he-IL', {
style: 'currency',
currency: 'ILS',
}).format(1234.5);
// "1,234.50 ₪"
Bidirectional Text Challenges
When embedding RTL-formatted numbers in HTML, use the dir attribute:
<span dir="auto">١٬٢٣٤٫٥٠ ر.س.</span>
Date Formatting in RTL
new Intl.DateTimeFormat('ar-SA', { dateStyle: 'full' })
.format(new Date('2025-03-15'));
// Arabic text with Hijri calendar, RTL layout
new Intl.DateTimeFormat('he-IL', { dateStyle: 'full' })
.format(new Date('2025-03-15'));
// Hebrew weekday and month names, Western digits
Forcing Western Digits in Arabic
Some applications need Arabic text with Western (Latin) digits:
new Intl.NumberFormat('ar-SA-u-nu-latn').format(1234567.89);
// "1,234,567.89" (Latin digits with Arabic formatting rules)
The -u-nu-latn Unicode extension forces Latin digit rendering.
Use Case
RTL number formatting is crucial for applications serving Arabic-speaking and Hebrew-speaking users. Banking apps in Saudi Arabia and the UAE must display amounts with Eastern Arabic digits. E-commerce platforms targeting the Middle East need correct currency formatting with SAR, AED, and other regional currencies. Government and healthcare applications in Israel need Hebrew-formatted dates and numbers. Understanding bidirectional text handling prevents display issues where numbers appear reversed or incorrectly positioned.
Try It — Locale String Tester
Related Topics
Intl.NumberFormat Basics: Locale-Aware Number Formatting
Intl.NumberFormat
Currency Formatting by Locale with Intl.NumberFormat
Intl.NumberFormat
Date and Time Formatting by Locale with Intl.DateTimeFormat
Intl.DateTimeFormat
Number Grouping Styles by Locale: Indian, Western, and East Asian
Intl.NumberFormat
Japanese Era Calendar Dates with Intl.DateTimeFormat
Intl.DateTimeFormat