Text diff
Load sample Compare is brown→red, jump+s→jump+ed, lazy→sleeping. Not a git or PDF diff.
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. Load sample 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. It is not a line-based git diff, a PDF compare, or a three-way merge. Nothing is uploaded.
Original
Modified
How it works
- Compare is a button, not as-you-type. Load sample fills Original
The quick brown fox jumps over the lazy dog.and ModifiedThe quick red fox jumped over the sleeping dog.and does not run Compare. Compare stays disabled until both boxes have text. Nothing is sent to a server. - The page constructs a
DiffMatchPatchinstance and callsdiff_main(text1, text2)(character-level), thendiff_cleanupSemanticso neighboring inserts and deletes group into readable hunks. Load sample Compare writes a deletedbrownbeside an insertedred. - Each hunk is type
-1(delete),1(insert), or0(equal). After semantic cleanup,jumpsvsjumpedkeeps the sharedjumpequal and paints a deletedsbeside an inserteded. The text is HTML-escaped (&,<,>) and newlines become<br>. - The result is inline HTML, not a unified diff. Replacements show as a deletion beside an insertion — there is no third "modified" span. Load sample also deletes
lazyand insertssleeping. This tool compares pasted text only, not uploaded files or PDFs.
FAQ
- Does this tool upload my text?
- No. Compare runs entirely in your browser. The page does not send either text box to a server.
- What algorithm does the comparison use?
- Google's diff-match-patch (the npm package of the same name). Compare calls diff_main(original, modified), then diff_cleanupSemantic so adjacent inserts and deletes are grouped into more readable hunks. The result is a list of operations: -1 delete, 1 insert, or 0 equal. Load sample is the pangram pair. 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.
- Is this a line-based git-style diff?
- No. The library diffs at the character level, then applies semantic cleanup. Newlines stay in the text and are rendered as line breaks. There is no unified-diff output, no file upload, and no three-way merge. Load sample fills the pangram pair and does not run Compare. Compare stays disabled until both boxes have text.
- How are replacements shown?
- There is no separate "modified" color. A replacement appears as a deletion next to an insertion. Deleted spans use strikethrough; added spans do not. Equal text is shown without a highlight. Load sample Compare is not three whole-word swaps: jumps vs jumped keeps jump equal. This is a pasted-text compare, not a PDF or binary file diff.