Text Diff
Compare two texts side-by-side — additions, deletions, and unchanged lines highlighted. Runs entirely in your browser.
Ctrl + Enter to compare
How text diff works
This tool uses the Myers diff algorithm, the same algorithm used by git diff and
most version control systems. Given two sequences of lines, it finds the shortest edit script
(SES) — the minimum number of insertions and deletions needed to transform text A into text B.
The output uses a unified diff-style display:
- Lines highlighted in green exist only in the modified text (added).
- Lines highlighted in red exist only in the original text (removed).
- Uncolored lines exist in both texts (unchanged).
Common text diff use cases
- Comparing two versions of a document, contract, or essay before and after edits.
- Checking what changed in a configuration file between environments.
- Verifying that a code transformation (minification, formatting, transpilation) only changed what was expected.
- Comparing API responses to find unexpected changes in payload structure.
- Reviewing student submissions vs. a reference answer.
Developer Guides
-
Myers Diff Algorithm: How git diff Finds Changes
A developer-friendly explanation of the Myers diff algorithm — the O((n+m)d) approach that powers git diff, unified diffs, and most modern code review tools.
-
How Does diff Work? The Algorithm Behind File Comparison
The diff utility uses the Longest Common Subsequence algorithm to find the minimal set of changes between two files. Here's how it works, step by step.
-
git diff Explained: Every Common Usage with Examples
A practical reference for git diff — comparing working tree, staged changes, branches, commits, and specific files. Includes output format and useful flags.