Text Compare
Diff by line, word or character, unified or side by side.
About Text Compare
A text compare tool shows the differences between two texts as you type, by line, word or character, unified or side by side, with changed words highlighted.
How to use
- Paste or load the original text on the left and the changed text on the right. The diff appears as you type; the swap button exchanges the two sides.
- Pick the granularity: Lines for code and config, Words or Characters for prose. Tick "Ignore whitespace" or "Ignore case" to hide those differences.
- In line mode, choose Unified (one column, with old and new line numbers) or Side by side. Unchanged runs are folded to three lines of context around each change; click a fold to expand it, or tick "Show unchanged lines".
- Step through changes with the up and down arrows next to the change count. Copy or download the result as a unified
diff.patch.
What it supports
- Line mode uses the Myers algorithm from the
diffpackage and runs in a Web Worker, so a large comparison never freezes the page; one over 5 seconds is stopped and reported. - A removed line followed by an added line is treated as a change: the words that differ are highlighted within the pair, so a one-word edit does not read as a whole-line rewrite.
- Word and character modes show one merged text with removed segments struck through in red and added segments in green.
- Limits: 10,000 lines per side in line mode, 100,000 characters per side in word and character modes, 2 MB per loaded file.
- The copied and downloaded patch is a unified diff named after the loaded files (or
originalandchanged), whichgit applyandpatchunderstand. - Identical texts are reported as identical, taking the ignore options into account.
Example
Original Changed
alpha alpha
beta beta
gamma ray gamma burst
1 1 alpha
2 2 beta
3 - gamma [ray]
3 + gamma [burst]
1 change · 1 line added · 1 line removed
Privacy
The comparison runs in the browser. No request is made, and nothing is stored.
Frequently asked questions
- What is a unified diff?
- A text format for describing changes between two files: a header naming the files, then hunks starting with @@ that list context lines, removed lines prefixed with - and added lines prefixed with +. It is the format produced by git diff and consumed by patch.
- What is the difference between a line diff and a word diff?
- A line diff treats each line as a unit, which suits code and configuration where lines are the natural unit of change. A word diff compares the running text, which suits prose, where a reflowed paragraph would otherwise show every line as changed.
- How do I compare two texts while ignoring spaces?
- Enable the "Ignore whitespace" option. Lines that differ only in spaces or tabs are then treated as identical, which hides indentation-only changes; in word mode, whitespace between words is ignored.
- How do I apply a .patch file?
- Save it next to the original file and run patch original < diff.patch, or git apply diff.patch inside a repository. The patch records the lines around each change, so it fails cleanly if the file has drifted.