// Text
Text Diff.
Side-by-side text diff with added and removed lines highlighted. Useful for code review and config changes.
Document A
Document B
Diff
FAQ
What algorithm is used?
A longest-common-subsequence line diff — the same algorithm used by classic diff tools. It surfaces added, removed, and unchanged lines.
Does it ignore whitespace?
No. Trailing whitespace is significant. If you want a relaxed diff, you can use the YAML diff tool which compares parsed values.
Why Text Diffing Matters
Text diffing is one of the most fundamental operations in software development and content management. Whether you are reviewing a pull request, comparing two configuration files, or tracking changes to a piece of documentation, you need a reliable way to see exactly what changed between two versions of a document. Without a diff tool, you would be forced to read both documents side by side and mentally identify every insertion, deletion, and modification. That process is slow, error-prone, and almost impossible when documents are long or have many interleaved changes. A diff tool automates this entire process, giving you a precise, line-by-line breakdown of every difference so you can focus on understanding the changes rather than hunting for them.
In code review workflows, diffs are the backbone of collaboration. When a teammate submits a change, the first thing you look at is the diff. It tells you exactly which lines were added, which were removed, and which remained untouched. This level of granularity is critical for catching bugs, evaluating design decisions, and ensuring that changes align with project standards. The same principle applies to configuration management. Server configs, environment files, and build scripts often evolve over time, and comparing the current version against a known-good baseline can quickly reveal a misplaced setting or an unintended override. Documentation teams rely on diffs as well, using them to track revisions, approve edits, and maintain a clear history of how content has evolved.
How the LCS Algorithm Works
Under the hood, this diff viewer uses the Longest Common Subsequence algorithm to compute differences between two documents. LCS works by finding the longest sequence of lines that appears in both documents in the same relative order, without requiring those lines to be contiguous. Once the algorithm identifies this shared backbone, it can classify every line in both documents as either part of the common subsequence (unchanged), present only in the first document (removed), or present only in the second document (added). This approach produces diffs that minimize the total number of highlighted changes, making the output easier to read and reason about compared to simpler line-by-line comparison methods.
The algorithm works by building a dynamic programming table. For each pair of lines from the two documents, it records the length of the longest common subsequence ending at that point. Once the table is complete, the algorithm traces back through it to reconstruct the actual diff. Lines that match between the two documents are marked as equal, while mismatches are resolved by choosing the path that yields the longest remaining common subsequence. The result is an optimally aligned diff that groups related changes together and avoids splitting single logical modifications into multiple scattered hunks. This is the same approach used by the classic Unix diff command and many modern version control systems, making it a well-understood and battle-tested method for text comparison.
Reading the Diff Output
The diff output is presented in a unified format that is both compact and easy to scan. Each line is prefixed with a symbol that indicates its status. A plus sign + marks lines that were added in the second document. A minus sign - marks lines that were removed from the first document. A space indicates lines that are present in both documents and have not changed. The color coding reinforces this information: added lines appear with a green-tinted background, removed lines appear with a red-tinted background, and unchanged lines are displayed in the default text color. This combination of symbols and colors makes it easy to absorb the diff at a glance, even for large documents with many interleaved changes.
When reading a diff, it helps to focus on the removed and added lines first, as these represent the actual changes. Unchanged lines provide context around the changes, helping you understand where in the document the modifications occurred. If you see a block of removed lines followed immediately by a block of added lines, that typically represents a modification where old content was replaced with new content. If you see only removed lines, something was deleted. If you see only added lines, something new was inserted. By scanning the diff in this way, you can quickly build a mental picture of what changed and why, without needing to read both documents in their entirety.
Common Use Cases
Code review. When working with a team, diffs are essential for reviewing changes before they are merged. By pasting the old and new versions of a file into this tool, you can instantly see every addition, deletion, and modification. This makes it straightforward to spot logic errors, style inconsistencies, or unintended side effects. Because this tool runs entirely in the browser with no server upload, you can safely diff proprietary or sensitive code without worrying about where the data goes.
Configuration comparison. Configuration files are notoriously difficult to compare by eye, especially when they contain nested structures, long lists, or subtle formatting differences. This diff tool lets you paste two versions of a config file side by side and immediately see what changed. Whether you are debugging a deployment issue, verifying that environment variables are set correctly, or auditing changes across environments, having a reliable diff output saves significant time and reduces the risk of overlooking critical differences.
Documentation changes. Writers and technical authors frequently need to review edits to long-form content. A diff tool makes it easy to see exactly which sentences or paragraphs were added, removed, or rewritten. This is especially valuable when collaborating on documentation with multiple contributors, where changes can be spread across many sections of a document. By generating a clear diff, reviewers can focus their attention on the parts that actually changed and approve edits quickly and confidently.
Data and log analysis. When comparing output logs, CSV exports, or structured text files, a line-level diff can reveal exactly where datasets diverge. This is useful for validating that a data pipeline produced the expected output, comparing test results across runs, or identifying the specific line where a log file began recording errors. The client-side nature of this tool means you can diff large text blocks without uploading them, keeping your data private and your workflow fast.
Learning and exploration. If you are learning a new programming language or framework, diffing your attempts against a reference implementation can be an effective way to identify mistakes and gaps in understanding. Paste your version into one pane and the expected version into the other, and the diff output will show you exactly what you missed or changed. This technique is simple, immediate, and one of the most practical ways to improve your skills through self-directed practice.