Skip to the guide
All guides

Modes and direction

RTLY decides direction one block of text at a time, from the letters in it. This page explains the rule, the three modes and the things RTLY deliberately does not touch.

app RTLY 2.1.0checked reading 7 minutes

On this page

The three modes

ModeDirection and alignmentFontUse it when
Full (default)YesYesYou want both.
FontNo changeYesThe site already handles direction, and you only want the font.
RTLYesNoYou like the site's own font and only want the direction fixed.

The mode is set per site, in the popup or on the settings page. A change applies to open tabs at once, without a reload. Switching a site off is separate: that stops RTLY on the site and reloads its tabs.

How direction is chosen

For each block of text (a paragraph, a list item, a heading), RTLY counts letters:

  • Letters from right-to-left scripts count as right-to-left: Arabic (which includes Persian, Urdu and others), Hebrew, Syriac, Thaana, N'Ko, Samaritan, Mandaic and Adlam.
  • The English letters A to Z and a to z count as left-to-right.
  • Digits, punctuation, spaces, emoji and letters of other scripts (Cyrillic, Chinese and so on) are not counted at all.

A block that starts with a right-to-left letter becomes right-to-left when at least 30% of the counted letters are right-to-left. The bar is 20% when the block contains a mark that only Arabic-script text uses: the Arabic comma, semicolon or question mark, a vowel mark, or the zero-width non-joiner used in Persian.

A block that starts with an English letter needs 30%. It is also right-to-left when at least 15% of its letters are Persian and it has two or more Persian grammar words, such as است, برای, با, را, و, or a verb that starts with می. Names and terms do not count, so an English sentence that ends with one Persian word stays left-to-right. With Prefer right-to-left in the Mixed-language lines setting on the settings page, these blocks use the same bars as the others.

Otherwise the block stays left-to-right. A block with no counted letters gets no direction.

The low bar is on purpose. Persian text is full of English terms such as React or npm, and it should still read right to left.

ExampleResultWhy
Run npm install را اجرا کنRight-to-left8 of the 21 counted letters (about 38%) are Persian.
BMAD یک framework برای Agile development استRight-to-leftIt starts in English and only 9 of 38 letters (about 24%) are Persian, but it has the grammar words یک, برای and است.
Please translate the word سلام for meLeft-to-right4 of 31 counted letters (about 13%) are Persian.
A paragraph in EnglishLeft-to-rightNo right-to-left letters.
12345 + 678No changeNo letters are counted.

When a block is right-to-left, RTLY sets dir, direction and the alignment so the text sits on the right. Left-to-right blocks are set the same way to the left, which looks the same as the site's default. Persian lines inside an English-majority block are still ordered correctly, because each line works out its own base direction.

Lists, headings and tables

Some blocks follow the text around them, so one answer does not read in two directions:

  • A list takes the direction of most of its items. A list that comes right after a right-to-left sentence follows that sentence, even when most items are English terms. English items keep their own direction and line up on the list's side.
  • When most paragraphs and list items of an answer are right-to-left, every heading with Persian or Arabic text is right-to-left too. A number at the start of a heading stays at its start.
  • A table follows its header row. When the header is right-to-left, cells with Persian text are right-to-left and English cells line up on the right.
  • Lines in one paragraph that start with numbers or bullets keep one direction, so the numbers stay on one side.

The font

The fonts are bundled in the extension, and the default is Vazirmatn. Pick a Persian or an Arabic font on the settings page; the one you pick is used for all Arabic-script text. RTLY applies it only to elements whose text contains Arabic-script characters. Arabic-script text in sidebars and menus gets the font too, but RTLY does not change its direction or layout. If you delete the Persian text from such an element and type English, RTLY takes the font off again, so English text keeps the site's own font and its line height.

The message box

The box where you type is not given a fixed direction. RTLY sets it to automatic and the browser follows the first strong letter of each line. Start a line in Persian and it is right-to-left. Start the next line in English and that line is left-to-right. In Font mode RTLY does not touch the direction of the box at all. If a line starts with an English word but is mostly Persian or Arabic, it reads right-to-left.

What RTLY leaves alone

  • Code and formulas. Code blocks, inline code and math formulas stay left-to-right. Code is not processed.
  • Sidebars, menus, headers and toolbars. RTLY recognizes them by their tags, roles and names. Conversation titles in the sidebar of Claude and Perplexity are the exception: a title that is mostly Persian is aligned to the right. Their Arabic-script text still gets the font. A direction or alignment the site gives its own menus stays as it is.
  • Icons and buttons that contain icons. Flipping them would swap the icon and its label. A paragraph, list item, heading or table cell with an icon in it, such as a source link, still gets its direction.
  • Very long containers. A single element with more than 5000 characters of text gets the font but no direction. The paragraphs inside it are handled one by one.
  • The page layout. On sites where Persian text could flip the whole page, RTLY keeps the top-level layout left-to-right so the sidebar stays on its side.
  • Other frames. RTLY works in the top page only, not in embedded frames.

Copying text

When you copy a selection that is mostly Persian from a right-to-left block, RTLY puts an invisible right-to-left embedding character in front of the text on your clipboard. This helps the text keep its direction where you paste it. Selections that are mostly English, and anything inside code, are copied as they are. For a Persian selection only plain text is copied, so formatting is not included.

Font size

The font size setting scales the page's base font size by a percentage (85% to 120%). Text that the site sizes in relative units follows it. Text that the site sizes in fixed pixels does not.

Streaming answers

While an answer is still being written, RTLY looks again after the page changes. A block can flip from left-to-right to right-to-left once enough Persian text has arrived.

Long chats

On a long chat, RTLY styles the messages near the screen first. The others get their style when you scroll toward them, a little before they come into view.