How to use Text Diff
- Paste the Original text on the left and the Changed text on the right.
- Show: Changes only prints a unified diff with a few lines of context. Whole text prints every line with a
+,-or space marker. - Context sets how many unchanged lines surround each change: 0, 3 (the usual default) or 10.
- Turn on Ignore whitespace or Ignore case to skip formatting-only differences.
- Copy the diff or Download it as
changes.diff, ready for a code review orgit apply.
The status bar counts the result, for example 3 lines added · 3 removed, or reports Texts are identical.
Reading a unified diff
--- original
+++ changed
@@ -1,8 +1,8 @@
server:
- port: 8080
+ port: 8443
host: 0.0.0.0
+ tls: true
logging:
- level: info
+ level: debug
features:
- search
- - export
| Line | Meaning |
|---|---|
--- original / +++ changed |
Which side is which |
@@ -1,8 +1,8 @@ |
Hunk header: starts at line 1 and spans 8 lines in each version |
server: (leading space) |
Unchanged context line |
- port: 8080 |
Line only in the original |
+ port: 8443 |
Line only in the changed text |
Nearby changes are merged into one hunk when their context overlaps, so a diff with 3 context lines often has a single hunk for a short file.
Tips
- Line endings don’t matter. Windows (CRLF) and Unix (LF) line endings are normalized before comparing, and a trailing newline at the end of the text is ignored.
- Re-indented code: use Ignore whitespace to see only the lines whose content changed.
- JSON or YAML data: reordered keys make text diffs noisy. Convert with YAML to JSON if needed and compare with JSON Diff, which ignores key order.
- Large inputs: up to 100,000 lines combined can be compared in the browser.
- Swap sides: the swap button on the Original pane flips the two texts, turning additions into removals.
- Sharing a comparison: Share copies a link that holds both texts in the URL fragment, which is never sent to the server. Anyone with the link can read the texts, so treat it like the data itself.
The same diff on the command line
diff -u original.txt changed.txt # unified diff, 3 lines of context
diff -u -w original.txt changed.txt # ignore all whitespace
git diff --no-index original.txt changed.txt
git diff --no-index -U10 a.txt b.txt # 10 lines of context
To find patterns rather than differences, try the Regex Tester.
Frequently asked questions
What algorithm does the diff use?
The Myers O(ND) algorithm, the same family git uses by default. It finds a minimal set of inserted and deleted lines, so small edits produce small diffs.
Can it compare files?
Yes. Drop a file onto either pane or use its open-file button. Files are read as text in your browser, up to 20 MB each.
Why don't I see changes inside a line?
The comparison works line by line: a line that changed appears as one removed line followed by one added line. For JSON documents, JSON Diff shows the exact path and values that changed instead.
What does Ignore whitespace do?
It trims each line and collapses runs of spaces and tabs before comparing, so re-indented or re-spaced lines count as unchanged. Ignore case compares lines case-insensitively. The output still shows the original text.
Is my text uploaded?
No. Both texts are compared in your browser. Nothing is uploaded.
Last updated