How to Read a Diff: Text Comparison, Invisible Characters & Version Control
Red lines, green lines, mysterious symbols — a diff is just two versions of a text with the changes made visible. Here's how to read one, and the invisible-character traps that make two files look identical when they aren't.
The Anatomy of a Diff
A diff is produced by an algorithm that aligns two versions of a text and highlights the minimal set of changes. Most tools — including git — use the Myers shortest-edit-script algorithm, which finds the smallest sequence of insertions and deletions that transforms one text into the other.
A typical unified diff looks like this:
-const users = ["alice", "bob"];
+const users = ["alice", "bob", "carol"];
- Minus (−) lines were removed from the original.
- Plus (+) lines were added in the new version.
- No sign lines are unchanged context that helps you orient.
In side-by-side tools the same information is laid out in two columns: the original on the left, the changed version on the right, with aligned rows.
Three Granularities, Three Jobs
| Granularity | Best for | Example |
|---|---|---|
| Line | Code, configs, structured text | Which functions changed? |
| Word | Prose, documents, copy | Which words were reworded? |
| Character | Forensics, invisible chars | What bytes actually differ? |
The smartest tools apply a second inline pass: first align at line level, then run a word or character diff inside the changed lines. You get the structure of a line diff with the precision of a word diff — which is exactly what the Prescosoft Text Diff does.
The Invisible-Character Trap
Two files can look pixel-identical and contain different bytes. The culprits are Unicode characters that render as nothing:
| Character | Code point | What it does |
|---|---|---|
| Zero-width space | U+200B | Invisible; breaks copy-paste and identifiers |
| Byte-order mark | U+FEFF | Silently prepended to files; shifts the first line |
| No-break space | U+00A0 | Looks like a space; breaks text comparison |
| Zero-width joiner / non-joiner | U+200D / U+200C | Invisible; corrupts names and emoji sequences |
| Thin / figure spaces | U+2009 / U+2007 | Invisible; common in typographically formatted text |
These characters sneak in through copy-paste from web pages, Microsoft Word exports, content-management systems, and imported data. They break hashes, string equality checks, and automated pipelines — while every human reviewer swears the files are identical.
The fix: diff at character granularity and scan for these code points explicitly. A character diff of two "identical" strings will show the zero-width space as an added or removed character, and a scanner will name the code point and its position.
Line Endings: The Other Silent Difference
Windows text files end lines with CRLF (carriage return + line feed, \r\n); Linux and macOS use LF (\n). Open a file in the wrong editor and save, and every line can change — a diff that shows the whole file modified when you "changed nothing."
A good diff tool reports line-ending styles explicitly (CRLF vs LF vs lone CR) and flags mixed endings, so you can tell a real change from an editor artifact.
How to Read a Diff Like a Developer
- Read the summary first. Similarity percentage and added/removed counts tell you the scale of the change before you dive in.
- Skim the removed lines. Deletions usually carry more meaning than additions — something was deliberately taken out.
- Look at changed-line pairs. A removed line followed by an added line is usually an edit, not a delete-plus-insert.
- Use word mode for prose. Whole-line diffs on documents hide which words actually moved.
- Check invisible characters before debugging. If the diff says "identical" but your checksum changed, scan for U+200B and friends.
Compare Locally — Your Code Stays Yours
Source code is intellectual property. Uploading it to a web diff service means sending it to a third party — some services keep pastes public, and some use uploaded content for training.
The Prescosoft Text Diff runs entirely in your browser: paste two versions, switch between line, word, and character granularity, flip between inline and side-by-side views, and get the invisible-character scan — all without a single byte leaving your device. No account, no watermark, no limits.
Frequently Asked Questions
How do I read a diff?
A diff shows two versions of a file with the changes highlighted. Lines that were removed start with a minus sign and are usually shown in red; lines that were added start with a plus sign and are shown in green; unchanged context lines have no sign. Line numbers on the left refer to the original file and on the right to the changed file. Changed lines may be split further into word-level highlights showing exactly which words moved.
Why does diffchecker show two files as identical when they aren't?
Because of invisible Unicode characters. Zero-width spaces (U+200B), byte-order marks (U+FEFF), no-break spaces (U+00A0), and zero-width joiners (U+200D) render as nothing or as ordinary spaces, so two files can look pixel-identical while containing different bytes. Many diff tools normalize or ignore these characters and report 'no difference'. A character-granularity diff with an invisible-character scanner exposes them — this is exactly what the Prescosoft Text Diff tool does.
What is the difference between line, word, and character diff?
Line diff compares whole lines and is best for code. Word diff compares within lines, highlighting the exact words that changed — best for prose. Character diff compares every individual character, which is essential for detecting invisible-character changes and byte-level differences. The right choice depends on what you're comparing: code reviews want line granularity, document edits want word granularity, and forensic comparisons want character granularity.
Is it safe to upload code to online diff tools?
Uploading proprietary source code to a web diff service sends your intellectual property to a third party. Some services keep pastes public, and some use uploaded content for training data. A local diff tool like the Prescosoft Text Diff runs entirely in your browser — your code never leaves your device, with no account and no tracking.
What is the Myers diff algorithm?
The Myers algorithm (1986) finds the shortest edit script — the minimal sequence of insertions and deletions that transforms one text into another — in near-linear time. It's the algorithm behind git diff and most diff tools. It guarantees a minimal diff, which is why well-aligned changes are easy to read even in huge files.
Why does my file show a diff after only opening it in an editor?
The most common cause is line-ending changes: Windows editors save with CRLF (carriage return + line feed) while Linux and macOS use LF, so a file that 'didn't change' shows every line modified. Other causes include a trailing newline being added or removed, and invisible characters like BOMs being inserted at the start of the file.
See the difference — including the invisible one
Line, word, and character diffs with an invisible-character scanner. Nothing uploaded, ever.