Make Arabic read the right way in LTR apps
You paste a clean Arabic phrase into a left-to-right field — a button label, a JSON value, a chat message — and the punctuation jumps to the wrong side or the whole run reverses. The text is fine; the layout engine just resolved its direction wrong. This tool wraps the snippet in the correct invisible Unicode bidi controls so it renders properly wherever you paste it.
Why bidi goes wrong
The Unicode bidirectional algorithm (UBA, Unicode Standard Annex #9) is responsible for determining the visual order of characters on screen. It works well for text that is clearly one direction, but mixed-direction content — Arabic words alongside Latin letters, digits, or punctuation — requires the algorithm to make decisions about neutral characters such as spaces, parentheses, and colons.
In a left-to-right context, neutral characters resolve to left-to-right direction by default. An Arabic run embedded in an LTR field can have its surrounding punctuation flip to the wrong side because the algorithm sees the LTR context as the base and resolves neutral characters accordingly.
Common symptoms:
- A trailing parenthesis or quotation mark appears on the left instead of the right
- The entire Arabic phrase appears in reverse visual order
- An Arabic phrase embedded in an English label has its first and last words swapped
- Phone numbers or codes embedded in Arabic text appear in the wrong order
How it works
The Unicode bidirectional algorithm decides direction from the characters present and their context. By bracketing your text with explicit control characters, you override that guess for just that run. The tool offers four methods, strongest isolation first:
- RLI…PDI — right-to-left isolate. Sets RTL and hides the run from the outer context (recommended).
- FSI…PDI — first-strong isolate. Direction is taken from the first strong character inside.
- RLE…PDF — legacy RTL embedding. Sets RTL but still interacts with surrounding text.
- RLM marks — lightweight zero-width bracketing for neutral characters.
A live preview renders the wrapped output inside a deliberately left-to-right box so you can confirm the fix before copying.
Choosing the right method
| Situation | Recommended method |
|---|---|
| Arabic phrase in an English UI label | RLI…PDI |
| Bidirectional paragraph (mixed Arabic + English) | FSI…PDI |
| Legacy system that does not support isolates | RLE…PDF |
| Just a trailing punctuation mark misbehaving | RLM marks |
The isolate methods (RLI and FSI) are the modern recommendation because they create a bidi context that cannot leak into the surrounding paragraph. The legacy embedding (RLE…PDF) was the only option before Unicode 6.3 introduced isolates, and some older environments still only support it.
Tips for developers
If you are building a web application that displays Arabic content, the cleanest
fix is to set dir="rtl" on the HTML element or to use the CSS property
direction: rtl on the containing element, rather than inserting bidi control
characters into the string. Reserve the control characters for cases where you
cannot control the rendering environment — API responses that go into third-party
apps, CSV files pasted into spreadsheets, or strings embedded in JSON that will
be displayed by an engine you do not control.