How to Identify the Left-to-Right Mark (LRM) in Unicode

Find and identify the invisible Left-to-Right Mark (U+200E): what it does to text, its byte signatures, and how to detect, verify and safely remove it.

The Left-to-Right Mark (LRM) is an invisible Unicode character with the code point U+200E. It has no glyph and takes up no width, so you cannot see it. It can still change how the surrounding text is displayed, and it can make two strings that look identical compare as different. This guide explains what the character does and how to confirm its presence by code point. It also covers how to decide whether to remove it without damaging meaningful text.

What the Left-to-Right Mark does to your text

LRM exists for the Unicode Bidirectional Algorithm. This is the set of rules that decides display order when text mixes left-to-right scripts, such as Latin, with right-to-left scripts, such as Hebrew or Arabic. Neutral characters, such as spaces and most punctuation, take their direction from the characters around them. LRM acts like a strongly left-to-right letter in those rules, but it displays nothing. A common use is placing it after a period or closing parenthesis, which keeps that punctuation visually attached to a left-to-right run inside right-to-left text.

LRM only changes visual order. It does not reorder the stored characters around it. It is still a real character in the data, though. It counts toward string length and breaks exact-match searches and equality checks. It can also cause sorting or deduplication to treat look-alike values as distinct, and it can make identifiers, keys or filenames fail to match. In text that contains no right-to-left characters, it usually has no visible effect, which is why stray copies tend to go unnoticed.

It usually enters text through copy and paste from applications or pages that handle mixed-direction content. Some software also inserts it on purpose to stabilize how mixed-direction text displays.

Key identifiers for LRM

Property | Value
Code point | U+200E
Character name | LEFT-TO-RIGHT MARK
General category | Cf (Format)
Bidirectional class | L (Left-to-Right)
UTF-8 bytes | E2 80 8E
UTF-16 code unit | 200E (bytes 0E 20 little-endian, 20 0E big-endian)
HTML named reference | ‎
HTML numeric references | ‎ or ‎
Escape in Python, JavaScript and JSON strings | \u200E

Characters often confused with LRM

Code point | Name | How it differs
U+200F | RIGHT-TO-LEFT MARK | Opposite direction; UTF-8 bytes E2 80 8F
U+061C | ARABIC LETTER MARK | Right-to-left mark intended for Arabic; UTF-8 bytes D8 9C
U+200B | ZERO WIDTH SPACE | Invisible, but marks a line-break opportunity rather than a direction
U+200C / U+200D | ZERO WIDTH NON-JOINER / ZERO WIDTH JOINER | Control how neighboring characters join, not their direction
U+202A | LEFT-TO-RIGHT EMBEDDING | Opens an embedding that is closed by U+202C POP DIRECTIONAL FORMATTING
U+2066 | LEFT-TO-RIGHT ISOLATE | Opens an isolate that is closed by U+2069 POP DIRECTIONAL ISOLATE

In UTF-8, the bytes for LRM (E2 80 8E) and RLM (E2 80 8F) differ only in the final byte. Check that byte carefully when reading a hex dump.

Step 1: Look for signs of a hidden character

Several symptoms suggest that an invisible character is present:
• The cursor needs an extra arrow-key press to move past one spot.
• A string's reported length is larger than the number of characters you can see.
• Two values that look the same fail an equality check.
These symptoms do not tell you which character is responsible. The steps below identify it exactly.

Step 2: Inspect the bytes from the command line

A hex dump shows every byte, including invisible ones. In a UTF-8 file, LRM appears as the byte sequence e2 80 8e. The following illustrative example builds a test string with one LRM between "abc" and "def". It relies on the \u escape of the bash printf builtin, which requires a recent bash and a UTF-8 locale.

printf 'abc\u200edef' | od -An -tx1

The output should take the following form. It was not run for this guide.

 61 62 63 e2 80 8e 64 65 66

To list the lines in a file that contain LRM, search for the raw byte sequence. Setting LC_ALL=C makes grep match bytes rather than locale-dependent characters. The $'...' quoting is bash and zsh syntax.

LC_ALL=C grep -n $'\xe2\x80\x8e' file.txt

To count every occurrence, not just the matching lines, print each match on its own line and count the lines:

LC_ALL=C grep -o $'\xe2\x80\x8e' file.txt | wc -l

These byte searches assume the file is UTF-8. A UTF-16 file stores LRM as 0E 20 or 20 0E, depending on byte order, so the patterns above will not find it.

Step 3: Identify the character by code point and name in a script

Python's standard unicodedata module reports a character's official name, general category and bidirectional class. The example below filters on category Cf, which covers LRM and the other format characters listed above. Every invisible format character is then reported by name, so you can tell them apart. To check a file instead, read it with open(path, encoding="utf-8").read().

import unicodedata

text = "abc\u200edef"  # example string containing one LRM
for i, ch in enumerate(text):
    if unicodedata.category(ch) == "Cf":
        print(i, f"U+{ord(ch):04X}", unicodedata.name(ch, "<unnamed>"), unicodedata.bidirectional(ch))

For this example string, the expected output is: 3 U+200E LEFT-TO-RIGHT MARK L. That line gives the position, the code point, the name and the bidirectional class.

In JavaScript, you can locate the character with indexOf and confirm its code point with codePointAt. The comments in this illustrative snippet show the expected values.

const text = "abc\u200Edef"; // example string
console.log(text.length);                      // 7, though only 6 characters are visible
console.log(text.indexOf("\u200E"));           // 3
console.log(text.codePointAt(3).toString(16)); // "200e"

Step 4: Check in a text editor

Some editors can display the code point under the cursor. In Vim, for example, the ga command shows the value of the character under the cursor in decimal, hexadecimal and octal. Placing the cursor on the invisible position should report hex 200e. Other editors may offer settings to highlight invisible or control characters, such as the Unicode highlighting options in VS Code. Defaults and behavior differ between editors and versions, and they were not tested for this guide. Confirm with a byte or script check whenever the result matters.

Step 5: Decide whether to keep or remove it

Removing LRM is generally safe in data that is meant to be purely left-to-right, such as IDs, codes, numbers, keys, filenames and spreadsheet fields. In mixed-direction prose, it may be deliberate. One example is an English product name followed by punctuation inside a Hebrew sentence. Removing the mark there can make the punctuation appear in the wrong place, so inspect the surrounding text before deleting anything.

Target U+200E specifically. Avoid broad filters such as stripping all non-ASCII characters, because they also destroy accented letters and right-to-left text. In Python:

cleaned = text.replace("\u200e", "")

On the command line, GNU sed can edit a UTF-8 file in place. The -i.bak option keeps a backup copy of the original:

LC_ALL=C sed -i.bak $'s/\xe2\x80\x8e//g' file.txt

To verify the result, run the search again; it should print 0. Then compare the cleaned file with the backup and confirm that only the invisible characters were removed. A cleaned string's length should drop by exactly the number of LRMs you counted earlier.

LC_ALL=C grep -c $'\xe2\x80\x8e' file.txt

Gaps and limits of this guide

No tool-specific documentation or test results were supplied for this guide. The commands and expected outputs are illustrative. They are based on standard Unicode properties of U+200E and the usual behavior of common tools, but they were not executed here. Shell quoting, locale handling, sed and grep variants, and editor display settings can differ between systems. Run each command on a sample copy before changing real files.