Compare Text Online and Identify Moved Passages
How online text comparison works, why moved passages often appear as a deletion plus an insertion, and how to choose a diff approach that shows moves clearly.
Comparing two versions of a document online seems simple. You paste both texts, and the tool highlights what changed. Moved passages are where many comparisons become misleading. A paragraph that was only relocated can look as if it was deleted in one place and newly written in another. This guide explains what a comparison actually reports, how to recognize a move in the output, which comparison approach suits which situation, and what to check before you rely on or share the result.
What a text comparison does and does not change
A comparison tool does not edit either input. It calculates a set of differences between the original and the revised text and presents them as a report. A typical report marks content as unchanged, inserted or deleted. Some tools add a fourth category for moved content. Your two texts stay the same; only the presentation of their differences is new.
The unit of comparison shapes the report. A line-based comparison treats each line as a single unit, so one changed comma marks the whole line as different. A word-based comparison isolates changed words inside a line. A character-based comparison isolates individual changed characters, which is precise but can be hard to read when many edits sit close together. Many tools combine these: they find changed lines first, then highlight the words or characters that differ within them.
Why moved passages are easy to miss
Many classic diff methods work by finding the longest sequence of content that appears in the same order in both versions. Everything outside that shared sequence is reported as deleted or inserted. A reordering breaks the shared order, so these methods have no way to describe a relocation directly. They report the passage as removed from its old position and added at its new one.
The following example is illustrative and was not produced by any specific tool. The original has three paragraphs in the order A, B, C. The revision has the same paragraphs in the order A, C, B, with no wording changes. An order-based diff might report it like this:
Paragraph A: Project scope and goals.
- Paragraph B: Budget assumptions.
Paragraph C: Delivery timeline.
+ Paragraph B: Budget assumptions.
A reader scanning that output could reasonably conclude that the budget section was deleted and rewritten. A move-aware comparison would instead link the two occurrences and label paragraph B as moved. It would not count the relocation as two separate edits.
Move detection has limits of its own. A move-aware method has to decide whether a deleted block and an inserted block are similar enough to count as the same passage. If the passage was edited as well as relocated, it may fall below that similarity threshold. In that case it appears as a deletion plus an insertion again. Very short moved fragments may also be ignored, because short strings often match by coincidence. Tools differ in how they set these thresholds, and not every tool documents them.
Stored characters versus visible appearance
A comparison works on the characters stored in the text, not on how the text looks on screen. This matters when either version has been through a text transformation. Two passages can look identical yet differ in stored characters, or look different yet be identical. The distinctions below determine what a comparison will report:
- Character-order reversal: the characters are stored in reverse order. A reversed passage will not match its original, even though it contains the same letters.
- Visual mirroring through CSS or another presentation layer: only the display is flipped, and the stored characters are unchanged. Comparing the underlying text shows no difference.
- Unicode character substitution: styled-looking letters produced by font generators, and lookalike characters from other scripts, are different code points from ordinary letters. A comparison reports them as changes, even though a reader may see the same word.
- Bidirectional display: right-to-left text and invisible direction-control characters can make the visual order differ from the stored order. A comparison follows the stored order, so highlighted ranges may look out of place on screen.
- Invisible characters: zero-width spaces, non-breaking spaces and similar characters can produce differences that have no visible mark.
- Unicode normalization: an accented letter can be stored as one precomposed character or as a base letter plus a combining mark. The two forms look the same but may be reported as different unless the tool normalizes them first.
Whitespace and line wrapping cause a related problem. If one version was reflowed, so that lines break at different points, a line-based comparison can flag almost every line in a paragraph whose wording did not change. Options to ignore whitespace or to compare by word reduce this noise, where a tool offers them.
How to recognize a moved passage in comparison output
Some tools label moves explicitly and many do not. When moves are not labeled, these clues suggest a relocation rather than a rewrite:
- A deleted block and an inserted block contain the same or nearly the same wording at different positions.
- The total amount of content is roughly unchanged, even though large blocks are marked as removed and added.
- The surrounding unchanged context jumps out of its original order. For example, a heading now sits in a different place relative to its neighbors.
- Searching the revised text for a distinctive phrase from a deleted block finds that phrase elsewhere in the document.
In a move-aware tool, a move is usually shown as a pair of linked locations, a distinct color or marker, or a label at both the old and new positions. The name and location of any move-detection setting vary by tool. No specific tool interface was examined for this guide, so check the documentation of the tool you use, or test it with the reordered-paragraph example above.
Choosing a comparison approach
The approaches below are compared on the criteria that matter most when passages may have moved. The descriptions summarize how each approach generally behaves. They are not observed results from particular products.
| Approach | How moves appear | Best suited to | Main tradeoff |
| Line-based diff | As a deleted block and a separate inserted block | Code, configuration files, lists and text with stable line breaks | Reflowed paragraphs and small in-line edits create noisy output |
| Word- or character-level diff | Usually as deletion and insertion, with finer highlighting inside changed lines | Prose edits where wording changes matter more than structure | Large reorganizations can be hard to follow |
| Move-aware diff | As a labeled or linked moved block, when similarity is high enough | Restructured documents, contracts, reports and reordered sections | Edited-and-moved passages may still be split, and thresholds are often undocumented |
| Manual check after any diff | You pair matching deletions and insertions yourself | Confirming a small number of suspected moves | Slow and easy to get wrong for long documents |
Choose by situation. If the revision mainly changes wording in place, a word-level comparison is usually clearest. If sections were reordered, a move-aware comparison avoids overstating how much was rewritten. Before you rely on its output, confirm the move feature with a quick test on a known reordering. If the text has fixed line structure, such as code or data, a line-based comparison is typically the most predictable. If either version may contain styled Unicode letters, invisible characters or mixed normalization, convert both to plain text first. Otherwise those character-level differences can hide the structural changes you care about.
Will the comparison output be readable and usable where you need it?
Copying and pasting: highlighting created with color or page styling often disappears when the result is pasted as plain text. Without markers, the reader cannot tell what changed. Output that uses text markers, such as plus and minus prefixes or explicit labels, survives a plain-text transfer far better. If you need to share a result, paste a sample into the destination first and confirm that the change indicators are still visible.
Accessibility: a comparison that marks changes only by color, such as red for deletions and green for insertions, can be unreadable for people with color vision deficiencies. Web accessibility guidelines advise against using color as the only way to convey information. Prefer output that also uses symbols, labels or strikethrough. Whether a screen reader announces highlighted changes depends on how the tool marks them up and on the assistive technology in use. This guide did not test that behavior, so check it in your own setup if it matters.
Compatibility: if the compared text contains bidirectional content, lookalike characters or invisible characters, the same report may display differently in different applications. If the output must be reliable in another environment, a plain-text version with explicit markers is the safest form to hand off.
Sensitive input: an online comparison tool may send the text you paste to an external server. Contracts, personal data, credentials or unpublished work could then be processed, logged or kept under the service's own policies. Before pasting confidential material, check whether the tool says it processes text only in your browser and what its retention policy is. When in doubt, use an offline comparison tool or redact identifying details first.
- Before relying on an online comparison:
- Convert both versions to plain text if they may contain styled Unicode, invisible characters or mixed normalization.
- Decide on line-, word- or move-aware comparison based on whether the revision changed wording, structure or both.
- Test move detection with a known reordering if moves matter.
- Check that change markers survive in the place you will paste the result.
- Confirm how the service handles your text before pasting anything sensitive.
Limits of this guide
No specific comparison tool was tested or documented for this guide. The diff example is illustrative, and statements about tool behavior describe general methods rather than any product's verified features. Before relying on a particular service's move detection, similarity thresholds, accessibility markup or data handling, check its documentation or run a controlled test.