A diff tool answers a deceptively simple question: what changed between these two texts? The question is simple; the answer requires care. Naive comparison would just flag every line that doesn't match character for character, but that misses the structure of real changes. A proper diff finds the minimal set of differences — the smallest edit that transforms one text into the other — and presents them in a way that makes both what changed and the surrounding context immediately clear.
The Text Diff Checker on DevToolShack compares two text blocks side by side, highlighting additions, deletions, and unchanged lines with color coding. It's useful for any situation where you need to know precisely what changed between two versions. Here is how it works and where it fits into a development workflow.
How Diff Algorithms Work
Most diff implementations are based on the Myers diff algorithm, published in 1986, which finds the longest common subsequence (LCS) between two sequences of lines. The LCS is the largest set of lines that appear in the same order in both texts without necessarily being contiguous. Lines in the LCS are "unchanged"; everything else is either added, removed, or replaced.
The intuition is: if you find the most that the two texts have in common, everything that isn't in common is the change. The algorithm produces the minimal edit that transforms text A into text B, which matters because a larger-than-necessary diff is harder to read and can obscure the real change.
Consider this example:
# Version A # Version B
line 1 line 1
line 2 line 2 (modified)
line 3 line 3
line 4 (removed) line 5
line 5
A naive comparison would show line 2 as changed, line 4 as removed, and everything else as unchanged. That's exactly what the diff algorithm produces — it correctly identifies the LCS as lines 1, 3, and 5, marks line 2 as a modification, and line 4 as a deletion.
Reading Diff Output
Diff tools use a standard color and symbol convention:
- Green / + — lines added in the new version
- Red / - — lines removed from the old version
- Unchanged lines — shown in the context around changes, usually in a neutral color
In a unified diff (the format used by Git), the output looks like this:
@@ -2,4 +2,3 @@
line 1
-line 2
+line 2 (modified)
line 3
-line 4 (removed)
line 5
The @@ header shows where in the file the change is: -2,4 means starting at line 2, showing 4 lines from the old file; +2,3 means starting at line 2, showing 3 lines in the new file. Context lines (unchanged) are shown with a space prefix to give you the surrounding code so you know where in the file you are.
In a side-by-side diff (like the one in the Text Diff Checker), the old and new versions are shown in parallel columns, with changes highlighted inline. This format is easier to read for shorter texts and when you're comparing prose rather than code.
Common Use Cases
Reviewing API response changes. When an upstream API changes its response format, pasting two JSON responses into a diff tool instantly shows which keys were added, removed, or changed. Much faster than reading both responses manually. For large JSON responses, formatting them first with the JSON Formatter normalizes indentation so the diff doesn't flag formatting differences as content changes.
Comparing configuration files. Diffing two versions of a config file (nginx, Apache, Kubernetes YAML, GitHub Actions workflow) shows exactly what changed between environments or deployments. This is a critical step in incident investigation when a configuration change is suspected.
Reviewing content edits. Writers and editors use diff tools to review revisions to documentation, blog posts, or marketing copy. The diff shows what was added or removed without requiring manual side-by-side reading.
Checking code output consistency. When refactoring a function that generates text output, diffing the output before and after the refactor confirms the behavior is identical.
Spotting unintended whitespace changes. Copy-paste operations, editor reformatting, and line-ending normalization can introduce whitespace changes that are invisible to the eye but show up as diffs. A diff tool catches these before they pollute a commit.
Git Diff and Browser Diff Tools
Git's built-in git diff command is the standard tool for comparing file versions in a version-controlled project. It shows all changes between the working tree and the last commit, or between any two commits. But git diff only works within a git repository, requires a terminal, and only operates on files.
A browser-based diff tool like the Text Diff Checker works on any text you can paste — JSON blobs, API responses, log excerpts, configuration snippets, prose — without needing a repository or a terminal. The two tools are complementary rather than competing.
Diff Tools for Specific Data Types
Text diff works on any line-oriented content, but some data types benefit from more specialized comparison:
JSON semantic diff. A standard text diff of two JSON objects will flag any formatting difference as a change, even if the underlying data is identical. A semantic JSON diff parses both objects and compares their structure, ignoring formatting. For quick JSON comparison, formatting both documents identically before diffing them achieves a similar result.
Word-level diff. Some diff tools offer word-level comparison rather than line-level, which is more useful for prose. When a single sentence changes, line-level diff flags the whole line; word-level diff shows exactly which words changed within the line. The Text Diff Checker highlights changed lines; for word-level comparison of prose, this gives you the changed lines to examine in detail.
For removing exact duplicate lines from a list — a related but different operation — the Duplicate Line Remover handles that without needing a comparison target. And for the inverse of diffing (merging sorted content and removing duplicates), the Sort Lines tool combined with the Duplicate Line Remover covers that workflow.