Diff Viewer
Compare two texts side-by-side with line-by-line diff highlighting. Clearly shows additions ■, deletions ■ and modifications ■. Works with plain text, JSON, YAML, configs and code.
What is a Diff Viewer?
A diff viewer compares two blocks of text and highlights the differences between them — additions shown in green, deletions in red — either in a side-by-side layout or inline. For DevOps and SRE engineers, it is an indispensable tool when reviewing configuration changes, comparing Terraform plan outputs, auditing migration scripts, or understanding what changed between two versions of a log file or manifest without needing a full Git repository.
The word "diff" comes from the Unix diff utility introduced in 1974, which became the foundation for version control systems and code review workflows. While tools like Git provide diff functionality in development workflows, there are many situations where engineers need a quick, standalone comparison outside of any VCS context — comparing a running configuration fetched via API against the desired state, or checking two versions of a shell script before deploying.
When to Use This Tool
- Config drift detection: Compare the running configuration of a service or database against the version checked into source control to identify unauthorised or undocumented changes.
- Terraform and Kubernetes review: Paste before and after versions of a Terraform plan or Kubernetes manifest to get a clear visual of what resources will be changed or replaced.
- Migration script validation: Compare the original SQL schema or data file against the migrated version to verify that only the intended changes were applied.
- Incident investigation: Spot changes in log output between a known-good timestamp and the time of an alert to identify the first anomalous line.
How It Works
The viewer splits each input into an array of lines and runs a longest-common-subsequence (LCS) algorithm to identify the maximal set of unchanged lines between the two texts. Lines that appear in the left input but not in the LCS are marked as deleted; lines in the right input not in the LCS are marked as added. For lines that are similar but not identical (modified lines), the viewer applies a secondary word-level LCS pass to highlight exactly which words within the line changed, providing sub-line precision that is especially useful for spotting small value changes in YAML and JSON configs.
Frequently Asked Questions
What diff algorithm does this tool use?
The tool uses a line-by-line comparison algorithm based on the longest-common-subsequence (LCS) approach — the same fundamental algorithm underlying Unix diff and Git's diff engine. It identifies added, deleted, and modified lines between the two inputs. For lines that are present in both texts but with small changes, the viewer applies a secondary word-level diff pass that highlights exactly which tokens within the line were modified, providing precise change identification that is far more useful than just knowing a line changed.
Can I compare Kubernetes YAML files?
Yes. This tool works with any text-based format including YAML, JSON, XML, HCL (Terraform), shell scripts, and plain text. It is particularly useful for comparing before and after versions of Kubernetes manifests — paste the output of kubectl get deployment myapp -o yaml alongside the version from your Git repository to immediately see any configuration drift. The word-level highlighting makes it easy to spot a changed image tag, resource limit value, or environment variable in a lengthy manifest without scanning every line manually.
What is the difference between unified diff and side-by-side diff?
A unified diff (like the output of git diff) shows both old and new content in a single column, using + and - prefixes to indicate additions and deletions — it is compact and works well in terminals and code review systems that render it with colour. A side-by-side diff places the original and modified versions in two parallel columns, making it much easier to visually track which specific lines changed and how, especially in files where edits are scattered across many locations. Side-by-side is generally preferred for reviewing configuration changes, while unified diff is the standard for Git commits and pull requests.