Text Diff Tool - Compare two files line-by-line
Compare two texts or files side-by-side to highlight additions, deletions, and differences.
How it works
Paste two texts and additions (green) and removals (red) are highlighted. Switch between line and word level for finer or coarser comparison.
About this tool
The diff tool compares two texts and highlights the differences line by line or character by character. It is useful when you want to see what actually changed between two versions of a contract, a config file, source code or a letter, without hunting manually. The tool runs entirely in the browser and supports both plain text diffs and structural comparison of JSON. Green marks additions, red marks removals, and you can switch between "unified" view and side-by-side.
How to use it
- Paste the "old" version in the left panel and the "new" one on the right.
- The tool updates the diff live, colouring additions and removals.
- Toggle between "line diff" and "character diff" as needed; character diff is useful for short texts.
- For structural JSON comparison, enable "JSON mode" in the toolbar; it ignores key order.
Examples
Hello world
This is text
EndHello world
This is new text
End{"a":1, "b":2}{"b":2, "a":1}Common use cases
- Compare two versions of a contract or memo.
- See what changed in a config file before committing.
- Debug why an API response suddenly looks different.
- Verify that a translation has not lost any sentences.
- Check whether two JSON streams from different systems are semantically equal.
Frequently asked questions
- What is the difference between "unified diff" and side-by-side?
- Unified stacks before/after lines in one column, like git diff. Side-by-side shows two columns simultaneously and is easier to read for large changes. Pick whichever gives fastest overview.
- Is my text safe?
- Yes. All comparison happens in the browser. Nothing is sent to a server, and the text disappears as soon as you close the tab.
- Does the tool handle large files?
- Up to a few MB per side is fine on a modern machine. Diffing is quadratic in the worst case, so two 10-MB files can take several seconds. Split into chunks if it gets slow.
- Can I ignore whitespace?
- Yes. Toggle "Ignore whitespace" in the toolbar; differences in spaces, tabs and line breaks are then dropped. Handy when comparing formatted vs unformatted code.
Technical background
Classic diff builds on the Myers algorithm from 1986, which finds the longest common subsequence (LCS) between two files with O((N+M)·D) complexity, where D is the number of differences. The algorithm underlies GNU diff, git, Mercurial and nearly every diff viewer in modern code editors. Character diff uses the same principle at character granularity, with small tweaks to produce readable highlights. For structural JSON comparison the tool parses both sides as JavaScript objects and performs a deep comparison, ignoring key order and whitespace. Some diff implementations use heuristics for "trivial" changes, ignoring blank lines, whitespace-only edits, matching partially moved blocks, or using patience diff (popular in git 2.11+) for cleaner groupings. Diff is also the foundation for merge tools, which try to combine changes from two branches without manual intervention.