Compare Two Texts with diff-match-patch
Docify's text diff compares two pasted strings in the browser with Google's diff-match-patch: it runs diff_main then diff_cleanupSemantic, and paints delete, insert, and equal spans. The example Compare writes a deleted brown beside an inserted red, keeps the shared jump equal and paints a deleted s beside an inserted ed, then a deleted lazy beside an inserted sleeping. Click Compare; it is not as-you-type. Replacements are delete-plus-insert — there is no yellow “modified” span. Compare does not call String.prototype.normalize. Compare of NFC é vs NFD e + U+0301 produces a deleted é beside an inserted e + U+0301. Reverse returns a deleted e + U+0301 beside an inserted é. Compose e + U+0301 to é (U+00E9) on /unicode-normalize/. Try it with the pangram pair. Nothing is uploaded.
This is a character-level pasted-text compare, not a line-based git diff, a Word Track Changes pane, or a PDF file checker.
How to compare two texts
Step 1: Paste Original
Put the older version in the Original box. Compare stays disabled until both boxes have text.
Step 2: Paste Modified
Put the newer version in the Modified box; click Compare when both boxes have text. With this pair the result deletes brown and lazy and the s after jump, and inserts red, ed, and sleeping.
Step 3: Click Compare
The page constructs a DiffMatchPatch instance, calls diff_main(text1, text2), then diff_cleanupSemantic. The Differences card appears only after that click.
What the colors mean
| Operation | Type | How it looks |
|---|---|---|
| Delete | -1 | Red background, strikethrough |
| Insert | 1 | Green background, no strikethrough |
| Equal | 0 | Unhighlighted foreground text |
The legend on the Differences card lists Deleted and Added only. Replacing brown with red shows a deleted brown beside an inserted red. After semantic cleanup, jumps vs jumped keeps the shared jump equal and paints a deleted s beside an inserted ed. That is not a whole-word jumps hunk. There is no yellow “changed” span.
How the HTML is built
Each hunk's text is escaped (&, <, >) so pasted markup cannot become live HTML. Newlines become <br>. The result is inline spans, not a unified diff file. There is no Copy or Download on the result.
Compare two pasted texts
Click Compare after both boxes have text. Deletes and inserts only. Nothing is uploaded.
Use Text Diff →FAQ
- How does this text comparison work?
- Paste two versions of your text and click Compare. The tool uses Google's diff-match-patch library to highlight additions and deletions.
- Does this tool upload my text?
- No. All comparison runs in your browser using JavaScript. Your text is never sent to a server.
- Is this a line-by-line diff?
- No. This tool compares at the character level with semantic cleanup, not line-by-line like git diff.
- How are replacements shown?
- Replacements appear as a deletion (strikethrough) next to an insertion (highlighted). There is no single "changed" color.
- Can I compare code files?
- Yes, you can paste any text including code. The comparison works on plain text regardless of format.