About this tool
Compare two texts side by side with word-level highlights, optionally ignoring edge whitespace or case, and export a standard unified patch. Ideal for contract revisions, editorial changes and config diffs.
Typical uses
- Compare clauses before and after a contract revision
- See exactly what an editor changed
- Diff two versions of a configuration file
How to use
Paste or import two texts and optionally ignore edge whitespace or case.
Compare, inspect side-by-side line numbers and word changes, then copy or download a patch.
Paste pre-release and updated configurations into the two editors, then compare line numbers and highlights. Download a unified patch that preserves every original difference, including changes ignored in the view.
Up to 200K characters combined, 2000 lines per side and a 3-second worker timeout. Display options may ignore differences; the unified patch always retains all original differences.
Up to 200K characters combined, 2000 lines per side and a 3-second calculation limit. Complex inputs may need reducing. This compares and exports patches; it does not merge conflicts.
How lines are lined up: the Example text step by step
The comparison works on lines first. Each side is split into lines (the line break belongs to its line), and the diffArrays function of the jsdiff library finds the fewest deletions and insertions; jsdiff implements Myers’s 1986 O(ND) difference algorithm. Each run of deleted lines is then paired, in order, with the run of inserted lines that follows it: paired lines show as changed, the rest as plain removals or additions.
Press “Example” and then “Compare” and you get the table below, with + 4 − 3 in the summary. A changed line counts once as added and once as removed, so 3 changed lines plus 1 new line give +4.
| Old line | Original text | New line | Updated text | Type |
|---|---|---|---|---|
| 1 | Release 1.0 | 1 | Release 1.1 | changed |
| 2 | ∅ | 2 | ∅ | same |
| 3 | Status: draft | 3 | Status: published | changed |
| 4 | - Image tools | 4 | - Image editor | changed |
| 5 | - QR codes | 5 | - QR codes | same |
| 6 | - Text diff | added |
The two lines “Status: draft / - Image tools” against “Status: published / - Image editor” form one block and pair up by position. When a block has different lengths on each side, pairing still goes by position only, not by similarity:
| Old line | Original text | New line | Updated text | Type |
|---|---|---|---|---|
| 1 | title | 1 | title | same |
| 2 | one | 2 | four | changed |
| 3 | two | removed | ||
| 4 | three | removed | ||
| 5 | end | 3 | end | same |
“four” is paired with “one”, while “two” and “three” show as removed, though none of them is related. There is no move detection either: moving the first line to the end shows one removal and one addition (+ 1 − 1).
| Old line | Original text | New line | Updated text | Type |
|---|---|---|---|---|
| 1 | A | removed | ||
| 2 | B | 1 | B | same |
| 3 | C | 2 | C | same |
| 4 | D | 3 | D | same |
| 4 | A | added |
“Changes only” hides unchanged lines but keeps the original line numbers. “Swap” exchanges the two sides, so additions and removals trade places.
Ignore options, line endings and the final newline
“Ignore leading/trailing whitespace” trims the start and end of each line before comparing; spaces inside a line must still match. “Ignore case” lower-cases both sides before comparing. Lines with different line-ending types (LF, CRLF, CR) never match, even with both options on. In the table ␣ marks a space and [LF] / [CRLF] mark line breaks:
| Original | Updated | Default | “Ignore leading/trailing whitespace” | “Ignore case” | Notes |
|---|---|---|---|---|---|
| ␣␣␣␣port: 80 | port: 80 | + 1 − 1 | No differences with these options | + 1 − 1 | Indentation changes can be ignored. |
| a␣␣b | a b | + 1 − 1 | + 1 − 1 | + 1 − 1 | A double space inside the line is not leading or trailing. |
| Host: Example | host: example | + 1 − 1 | + 1 − 1 | No differences with these options | Case can be ignored. |
| a[CRLF]b[CRLF] | a[LF]b[LF] | + 2 − 2 | + 2 − 2 | + 2 − 2 | Windows and Unix line breaks: every line counts as changed and shows a CRLF / LF badge. |
| a[LF]b | a[LF]b[LF] | + 1 − 1 | + 1 − 1 | + 1 − 1 | Only the last line break differs: the last line counts as changed, with “No final newline” on the left and LF on the right. |
| done.␣␣ | done. | + 1 − 1 | No differences with these options | + 1 − 1 | Trailing spaces can be ignored. |
- “Texts are identical” means the two texts are byte-for-byte equal; “No differences with these options” means only ignored differences remain. The downloaded patch still contains those.
- Text you paste or type into the editors always gets LF line breaks, whereas files loaded with “Import original” / “Import updated” keep their CRLF or CR. Comparing an imported Windows file against pasted text therefore marks every line as changed. Import both sides, or paste both.
- Editing an imported side in the editor converts that side to LF as well.
Word highlights: which part of a line gets marked
With “Word highlights” on, each pair of changed lines is compared again word by word. The tokens are: a run of letters, digits and underscores is one word; each run of spaces is one token; each punctuation mark is its own token; each Chinese character and each Japanese kana is a token of its own, even right after a digit or a Latin letter. Brackets show the highlighted parts:
| Original | Updated | Highlighted (old → new) | Why |
|---|---|---|---|
| colour scheme | color scheme | [colour] → [color] | Whole words are marked. |
| version=1.2.3 | version=1.2.4 | [3] → [4] | Dots are punctuation tokens, so only the last digit is marked. |
| Le café est prêt. | Le cafe est prêt. | [café] → [cafe] | é and e differ; the case and whitespace options do not touch accents. |
| Host: a b | Host: a b | [␣␣] → [␣] | Highlights ignore the whitespace option, so a different number of spaces is still marked. |
| 已完成审核 | 已通过审核 | [完成] → [通过] | Text starting with Han characters is compared one character at a time. |
| 发布时间:11月20日 | 发布时间:11月21日 | [20] → [21] | Digits and Han characters are split apart, so only the changed number is marked. |
When a line pair totals more than 2,000 characters, or after 120 changed pairs, further lines get whole-line highlighting only, with the note “Some long or complex lines show line highlights only; the patch contains all differences.”. Turning highlights off does not change the line comparison or the patch.
What the patch file contains
“Copy patch” and “Download patch” produce a unified diff (the GNU diff unified format) with the file names before.txt and after.txt and 3 lines of context around each change. The patch for the Example text is:
| Patch line | Meaning |
|---|---|
| =================================================================== | Separator |
| --- before.txt | Old file name |
| +++ after.txt | New file name |
| @@ -1,5 +1,6 @@ | Position of the hunk |
| -Release 1.0 | Only in the old file |
| +Release 1.1 | Only in the new file |
| ␣ | Context, same on both sides |
| -Status: draft | Only in the old file |
| -- Image tools | Only in the old file |
| +Status: published | Only in the new file |
| +- Image editor | Only in the new file |
| ␣- QR codes | Context, same on both sides |
| +- Text diff | Only in the new file |
- The --- and +++ lines name the old and new file. “@@ -1,5 +1,6 @@” means this hunk covers 5 lines of the old file starting at line 1 and 6 lines of the new file starting at line 1.
- A leading space marks a line common to both, - a line only in the old file, + a line only in the new file.
- The patch is always built from the original texts and ignores the ignore options; when they are on, the page says “The patch includes every original difference, including spaces and case ignored in this view.”
- Applied to the original, the patch reproduces the updated text byte for byte, including line-ending types and whether the file ends with a newline.
Limits and messages
| Message | When it appears |
|---|---|
| Use at most 200,000 characters across both sides. | More than 200,000 characters on both sides combined. |
| Each side is limited to 2,000 lines; compare a smaller section. | More than 2,000 lines on one side. |
| The comparison is too complex or timed out. Compare smaller sections. | More than 2,500 line insertions and deletions are needed, or the calculation ran out of time. Two completely different texts still compare at 1,250 lines each and fail at 1,251. |
| The comparison was stopped after timing out. Use smaller inputs. | The background calculation ran longer than 3 seconds and was stopped. |
| Text files are limited to 800 KB. | An imported file is over 800 KB. |
| File must use UTF-8 encoding. | An imported file is not valid UTF-8, for example a Windows-1252 text file with accented letters. Convert it to UTF-8, or open it and paste the text instead. |
| The comparison worker could not load. Refresh and try again. | The browser could not start the background worker. |
Comparison runs in a background thread of your browser; the text is not uploaded. A fully rewritten document is easier to review in sections. For structural JSON differences, or spreadsheet records matched by ID, the dedicated tools below give clearer results.
Sources
Frequently asked questions
Do ignore options affect the exported patch?
No. They only affect the display; the patch always contains every original difference.
How long can the texts be?
Up to 200,000 characters combined and 2000 lines per side.
Are my texts uploaded?
No. Comparison runs in a background worker in your browser.
Suggest an improvement to this tool
Missing an option, something awkward to use, or a wrong result? Let us know.