Compare two texts and see the differences.
Text diffing (or text comparison) is the process of finding differences between two versions of text. It's essential for tracking changes in documents, code reviews, plagiarism detection, and version control systems. This tool highlights what was added, removed, or changed between two pieces of text.
Text comparison algorithms analyze both texts and identify:
Text that appears in the modified version but not in the original. Shown in green.
Text that was in the original but removed in the modified version. Shown in red.
Lines that were modified. Shows both the old and new content highlighted in yellow.
Developers use diff tools to review code changes before merging. This helps identify bugs, security issues, and ensure coding standards are followed. Tools like GitHub, GitLab, and Bitbucket all have built-in diff viewers.
Writers, editors, and legal professionals use text comparison to track changes in contracts, manuscripts, and official documents. It ensures nothing important was accidentally deleted or modified.
Educators and publishers compare submitted work against original sources to detect copying. High similarity scores may indicate plagiarism that requires further investigation.
System administrators compare configuration files before and after changes to understand exactly what was modified. This is crucial for troubleshooting and audit trails.
The similarity score indicates how much text remains unchanged between the two versions:
| Similarity | Interpretation | Example Scenario |
|---|---|---|
| 90-100% | Nearly identical | Minor typo fixes, small edits |
| 70-90% | Mostly similar | Sentence rewrites, paragraph additions |
| 50-70% | Significant changes | Major revisions, restructuring |
| 0-50% | Mostly different | Complete rewrites, different content |
Several algorithms can compute text differences:
Text diff is the foundation of version control systems:
# Git diff commands
git diff # Compare working directory to staging
git diff --staged # Compare staging to last commit
git diff HEAD~1 # Compare to previous commit
git diff branch1..branch2 # Compare two branches
Git stores changes as diffs (called "deltas") rather than full file copies, making repositories efficient.
Green Added text
Red Removed text
Yellow Modified text