~/tools/text-diff
Text Diff
Compare two texts instantly — line-by-line diff with split and unified views. Zero server calls, zero data sent.
What is a Diff?
A diff (short for "difference") is an algorithm-generated comparison between two text inputs that pinpoints exactly what was added, removed, or remained unchanged. The concept was popularised by the Unix diff command, first released in 1974, and has since become foundational to version control systems like Git, code review platforms like GitHub and GitLab, and deployment tooling.
The most common diff algorithm is Myers' algorithm (1986), which finds the shortest edit script (SES) — the minimum number of insertions and deletions to transform one text into another. This is the same algorithm used by Git internally.
View Modes
Most diff tools offer two ways to display changes, and the best choice depends on the size and nature of your edit. Split view gives you spatial context by placing original and modified side by side — ideal when you need to see the before and after at the same time. Unified view is more compact, merging both versions into a single column in the same format you'll see in Git commit histories and pull request reviews on GitHub or GitLab.
Split View
Original on the left, modified on the right. Deleted lines appear only on the left, added lines only on the right. Best for reviewing short-to-medium changes.
Unified View
Both versions merged into a single column. Lines marked with + (green) are additions, lines with - (red) are deletions. Familiar from Git diffs and patch files.
Common Use Cases
A diff tool is useful whenever you need to understand exactly what changed between two versions of any text-based content. While most commonly associated with source code, developers reach for it across a wide range of everyday tasks — from auditing config changes before a deployment to proofreading a document revision. The unifying theme is always the same: you have two versions of something and you need to know precisely what is different.
- Comparing two versions of a config file (nginx, docker-compose) - Reviewing changes in a code snippet before committing - Checking what changed between two API responses (REST, GraphQL) - Proofreading document edits and contract revisions - Diffing SQL migrations or database schema changes - Comparing environment variable files (.env.local vs .env.production) - Auditing Dockerfile or GitHub Actions workflow changes - Comparing two versions of a localization/translation file * Enable 'Ignore whitespace' to focus on semantic changes only
How to Read a Diff
If you're new to reading diffs, the format can look noisy at first glance. Once you learn the three symbols — + for added, - for removed, and a plain space for unchanged — you can parse any diff output instantly, whether it comes from this tool, a Git pull request, or a patch file shared by a colleague. The example below uses the same unified format Git uses internally.