What is Text Diff?
Text diff is a tool for comparing differences between two texts. It uses the LCS (Longest Common Subsequence) algorithm to identify added, removed, and unchanged content. Commonly used for code review, document version comparison, configuration file diff checking, etc. Green background indicates added lines, red background indicates removed lines.
How to Use
- Paste original text in the left input box
- Paste modified text in the right input box
- The system automatically calculates and highlights differences, status bar shows added and removed line counts
Examples
Code Version Comparison
Original:
function hello() {
console.log('Hello');
}
New:
function hello(name) {
console.log('Hello, ' + name);
}
Diff: Function added parameter 'name', output statement changed to concatenate parameterConfig File Comparison
Original:
{
"port": 3000,
"debug": true
}
New:
{
"port": 8080,
"host": "localhost"
}
Diff: port changed from 3000 to 8080, debug removed, host addedFAQ
Q: What algorithm does text diff use?
A: This tool uses the LCS (Longest Common Subsequence) algorithm, a classic text difference detection algorithm that accurately identifies added, removed, and unchanged content.
Q: How large a text file can be processed?
A: This tool runs locally in the browser and can handle thousands of lines of text. Very large files may affect browser performance.
Q: Will my data be uploaded to the server?
A: No. All comparisons are done locally in your browser. Data is never uploaded to any server, protecting your privacy.
Q: Why are some lines not highlighted?
A: Unhighlighted lines indicate unchanged content. Only added (green) and removed (red) lines are highlighted.