Compare Text Differences Between Documents
How document comparison works at the character, word and line level, how to choose a granularity, and how to keep diff results readable, accessible and private.
When two versions of a document look almost the same, a comparison tool shows exactly what changed: which words were removed, which were added and which stayed. This guide explains what a text comparison does and does not do, how to choose between character-, word- and line-level comparison, and how to check that the result stays readable wherever you need to use it.
What a Document Comparison Actually Changes
A comparison does not change either document. It reads two inputs, splits each into units (characters, words or lines), and calculates the smallest set of deletions and insertions that turns the first version into the second. Most diff methods are based on finding the longest common subsequence: the units both versions share in the same order are treated as unchanged, and everything else is marked as removed or added. The output is a report of differences, not a new version of the text.
Because a comparison works on stored characters rather than on what you see, it can report a change where none is visible, or report nothing where the screen looks different. That distinction matters most when either document has been through some other text transformation.
- Character-order reversal: a reversed string stores its characters in the opposite order, so comparing it with the original usually marks nearly everything as changed, even though the same letters are present.
- Visual mirroring with CSS or another display effect: the stored characters are unchanged, so a comparison of the underlying text reports no difference, even though the displayed text looks flipped.
- Unicode character substitution: styled letters from "font generators" (such as mathematical bold or script letters) and lookalike letters from other alphabets are different code points from ordinary letters. A comparison treats them as different characters even when they look identical or nearly so.
- Unicode normalization: an accented letter can be stored as a single precomposed character or as a base letter plus a combining mark. Both render the same, but an unnormalized comparison reports them as different.
- Bidirectional text: Arabic, Hebrew and other right-to-left scripts are stored in logical (reading) order and reordered for display. A comparison works on the logical order, so a diff view that does not apply bidirectional display rules can show changed right-to-left words in a confusing visual order.
Labels such as "mirror text" or "font generator" do not tell you which of these methods a tool uses. If a document has passed through such a tool, check whether the stored characters changed before relying on a comparison result.
Choosing Character, Word or Line Comparison
The same pair of documents can produce very different-looking reports depending on the comparison unit. The example below uses one matched input pair to show the difference. The outputs are illustrative, written by hand to show how each granularity behaves; they are not captured from a specific tool, and real tools may tokenize punctuation and spaces differently. Here, [-text-] marks a deletion and {+text+} marks an insertion.
Original: The contract must be signed by Friday.
Revised: The contract should be signed by Monday.
Character level (illustrative):
The contract [-must-]{+should+} be signed by [-Fri-]{+Mon+}day.
Word level (illustrative):
The contract [-must-]{+should+} be signed by [-Friday.-]{+Monday.+}
Line level (illustrative):
[-The contract must be signed by Friday.-]
{+The contract should be signed by Monday.+}
| Granularity | What it marks | Best suited to | Main tradeoff |
| Character | Individual letters, spaces and punctuation | Typos, single-character fixes, code identifiers, spotting lookalike or normalization differences | Fragments words, so edits to whole words or phrases become hard to read |
| Word | Whole words (and, depending on the tool, attached punctuation) | Editorial revisions, contracts, essays, translated or reworded prose | May hide a one-letter change inside a word and can treat punctuation inconsistently |
| Line | Entire lines or paragraphs | Source code, configuration files, lists and structured data | A single changed word marks the whole line, which is unhelpful for long paragraphs |
For word-level revisions in prose, word comparison is usually the most readable starting point: it matches how editors think about changes. Switch to character comparison when you need to confirm exactly which letters differ, for example when two words look identical but a comparison still flags them. Use line comparison for text where line breaks carry meaning, such as code or data files.
Settings that change the result
- Whitespace handling: ignoring extra spaces, tabs and line-ending differences removes noise when documents were reflowed or saved on different systems.
- Case sensitivity: ignoring case hides capitalization edits, which is useful for content review but wrong for proofreading.
- Unicode normalization: normalizing both inputs to the same form prevents invisible encoding differences from appearing as edits.
- Line wrapping: if one version has hard line breaks and the other does not, a line-level comparison will flag almost every line; join paragraphs or use word comparison instead.
Check which of these options a tool offers in its own documentation rather than assuming a default. Two tools comparing the same files can disagree simply because one ignores whitespace and the other does not.
Plain-text comparison versus formatted documents
Plain-text comparison looks only at characters. Formatted files such as word-processor documents or PDFs must first be converted to text, and that step can lose or distort information: bold, italics and styles disappear, tables may flatten into runs of words, and text extracted from PDFs can arrive with broken hyphenation, extra line breaks or reordered columns. Some word processors include a document-compare function that tracks formatting as well as wording; confirm in your application's documentation what it detects. If formatting changes matter, use a comparison that reads the native format. If only wording matters, plain-text comparison is simpler and its results are easier to verify.
Keeping the Comparison Readable and Usable
A diff that is clear on screen can become ambiguous once it is copied, shared or read with assistive technology. Before sending a comparison to someone else, consider how they will receive it.
Copy and paste
Many diff views mark changes only with color, highlighting or strikethrough. Those are display formatting, not characters. When the result is pasted into a plain-text destination, such as a text editor, chat message or form field, the formatting is dropped and deleted and inserted words run together. In the example above, the pasted result could read "The contract mustshould be signed by FriMonday." with no indication of which word was removed. To transfer a comparison safely, export or copy it in a format that uses text markers, such as bracketed deletions and insertions or a unified diff with leading minus and plus signs, and paste a sample into the destination to confirm it survives.
Accessibility
Red and green highlighting alone is difficult to distinguish for many people with color-vision deficiencies. Whether a screen reader announces strikethrough, highlighting or color depends on the screen reader, the application and the user's settings, so do not assume a visually marked deletion will be spoken as one. Text markers, explicit labels such as "removed" and "added," or a side-by-side view with clear headings convey the same information without relying on color or formatting. If the documents contain styled Unicode letters, also be aware that screen readers may read those characters by their symbol names or skip them, which affects the readability of both the source and the diff.
Compatibility
How a diff report displays depends on the program that opens it. Formatted reports can lose their markup in email clients or messaging apps, and right-to-left text or combining characters may render differently across viewers. No single output format is guaranteed to display the same everywhere. When the comparison must be reviewed in a specific application, open a test copy there first.
Sensitive documents and online tools
Pasting text into a web-based comparison service sends the full content of both versions to that service. For contracts, personal data, unpublished work or anything under confidentiality obligations, read the service's privacy terms on storage and retention before uploading, or use a comparison tool that runs locally on your own device. If an online tool is the only option, remove or replace names, figures and identifying details first, and keep in mind that redaction itself will show up as differences if only one version is redacted.
Gaps in This Guide
No specific comparison tools were tested for this guide, so it does not rank products, quote their default settings or describe their exact output. The example outputs are illustrative. Before relying on any tool for important revisions, run a short test with a known pair of texts that includes a word change, a punctuation change and a whitespace change, and confirm the report shows each one the way you expect.