I Built rtl-text-tools ( A Complete RTL Text Processing Toolkit for JavaScript )
If you’ve ever worked with Arabic, Persian, Hebrew, Urdu, or any RTL (Right-to-Left) language on the web, you probably know the pain. Mixed RTL/LTR text rendering breaks unexpectedly. Punctuation looks wrong. Numbers don’t match the locale. Ellipsis appears on the wrong side. URLs inside Arabic text become unreadable. And emails or plain-text environments completely destroy formatting. After dealing with this problem repeatedly, I decided to build: rtl-text-tools A lightweight RTL text processing toolkit for JavaScript and TypeScript. It handles: RTL detection Direction normalization Arabic/Persian digit conversion RTL punctuation conversion Ellipsis fixing Unicode bidi wrapping CSS helpers DOM helpers And it works all the way back to IE11 with zero runtime dependencies. Why This Exists Most internationalization libraries focus on translations and formatting APIs. But very few actually solve the rendering problems of RTL text itself. For example: "مرحبا, رقم 123..." Visually, this often renders awkwardly in mixed-direction environments. You usually want: "...مرحبا، رقم ۱۲۳" That means: move ellipsis to the correct visual side convert punctuation convert digits preserve RTL readability That’s exactly what rtl-text-tools does. Installation npm install rtl-text-tools Quick Example import { fixRTL } from ' rtl-text-tools ' ; fixRTL ( ' مرحبا, رقم 123... ' ); // → "...مرحبا، رقم ۱۲۳" Arabic digits are also supported: fixRTL ( ' مرحبا, رقم 123... ' , { lang : ' arabic ' }); // → "...مرحبا، رقم ١٢٣" If the text isn’t RTL, it returns the original string unchanged: fixRTL ( ' Hello world ' ); // → "Hello world" Features 1. RTL Detection Detect whether text contains RTL scripts. import { hasRTL } from ' rtl-text-tools ' ; hasRTL ( ' مرحبا ' ); // true hasRTL ( ' שלום ' ); // true hasRTL ( ' Hello ' ); // false Supports: Arabic Hebrew Persian/Farsi Urdu Syriac Thaana N’Ko Samaritan Mandaic and more 2. Digit Conversion Convert Latin digits into locale-specific numerals. Persian