Compare two text files, code snippets, or any textual content side‑by‑side. Instantly see additions, deletions, and modifications with color‑coded highlighting.
A file diff checker (or diff tool) is a utility that compares two text files or code snippets and highlights the differences between them. It shows which lines have been added, removed, or modified, making it an essential tool for:
The diff algorithm finds the longest common subsequence (LCS) between two sequences, then uses that to determine which elements are common and which are unique to each sequence.
LCS(A, B) = max { |S| : S ⊆ A ∧ S ⊆ B ∧ S is a subsequence }
At its core, the diff algorithm is based on the Longest Common Subsequence (LCS) problem. Given two sequences of lines (the left and right texts), the algorithm finds the longest sequence of lines that appears in both texts in the same order. Once the LCS is identified, the remaining lines are classified as additions (only in the right text), deletions (only in the left text), or modifications (lines that correspond but differ in content).
The LCS problem is solved using dynamic programming. A matrix of size (m+1)×(n+1) is built, where m and n are the number of lines in the left and right texts. Each cell (i,j) stores the length of the LCS of the first i lines of the left text and the first j lines of the right text. The recurrence relation is:
After filling the matrix, a backtracking step reconstructs the LCS, and from that, the diff output is generated. This algorithm has a time complexity of O(m·n), which is efficient for texts up to several thousand lines.
Our implementation also supports optional pre‑processing steps: ignoring whitespace (normalizing spaces and tabs), case‑insensitive comparison, and trimming trailing spaces, giving you full control over how strict the comparison should be.
A software engineer opens a pull request with 47 changed files. Using this diff tool, they can quickly scan the most critical file – the core business logic – to verify that the new implementation correctly handles edge cases. The color‑coded diff reveals that two new conditional branches were added (green), one obsolete function was removed (red), and three lines were refactored (yellow). The reviewer can then focus their attention on the modified sections, speeding up the review process and reducing the chance of overlooking subtle bugs.
A legal team compares two versions of a contract. The diff tool highlights all changes: a clause was reworded (modified), a paragraph was inserted (added), and an outdated section was struck (deleted). The team can quickly assess the impact of the revisions and ensure that no critical terms were inadvertently altered. The export‑as‑HTML feature allows them to produce a redline document for client review.
An operations engineer needs to migrate a configuration file from an old environment to a new one. By pasting the old and new configs into the diff checker, they can see exactly which parameters were added, removed, or changed. This helps them update their deployment scripts and avoid misconfigurations that could cause outages.
| Status | Color | Meaning | Example |
|---|---|---|---|
| Unchanged | White | Line appears identically in both texts. |
const x = 42;
|
| Added | Green | Line is present only in the right (modified) text. |
console.log("new");
|
| Deleted | Red | Line is present only in the left (original) text. |
oldFunction();
|
| Modified | Yellow | Line exists in both texts but with differences. |
let y = 10; → let y = 20;
|
The LCS‑based diff algorithm works well for texts up to a few thousand lines. For very large files (e.g., 10,000+ lines), the O(m·n) time complexity may become noticeable. In such cases, we recommend splitting the file into logical sections or using a more specialized diff tool. The tool is designed for interactive use, not for batch processing of massive datasets.
All processing is done client‑side, so performance depends on your device's CPU and memory. For typical code files (a few hundred lines), results appear instantly.