What This Tool Does
This tool compares two blocks of text or code to find the exact differences. It highlights lines that were added, deleted, or modified. It supports both side-by-side and unified diff views.
Inputs Explained
- Original Text: The base or older version of your code/text.
- Changed Text: The newer version to compare against.
- View Mode: Side-by-side (two columns) or Unified (inline additions/deletions).
- Ignore Case: Treats uppercase and lowercase letters as identical.
How It Works
It uses a Longest Common Subsequence (LCS) / Myers diff algorithm to compute the shortest sequence of edits required to turn the original text into the changed text. It then renders the additions and deletions with color coding.
Formula / Logic Used
Diff Checker (Code & Text)
Compare text and code side-by-side to spot changes instantly.
Step-by-Step Example
Original: const a = 1;
Changed: const a = 2;
Unified Diff Output:
- const a = 1;
+ const a = 2;
Use Cases
- Code Review: Compare a downloaded file against your local version before merging.
- Plagiarism Check: Spot similarities and exact changes between two essays.
- Config Debugging: Compare two server `.conf` files to see what changed.
- Refactoring: Ensure logic wasn't accidentally deleted when restructuring code.
Assumptions and Limitations
- The current implementation is line-based. It does not highlight specific changed characters within a line.
- Very large files (10,000+ lines) may take several seconds to compute due to the O(ND) complexity of the Myers diff algorithm.
- Whitespace normalization is not fully supported; leading tabs vs spaces will be treated as differences.
- Does not support binary files (like images or compiled binaries).
Frequently Asked Questions
How do I ignore whitespace when comparing code?
In our Diff Checker, toggle "Ignore whitespace" — it normalises spaces, tabs, and trailing whitespace before comparing, so reformatting changes don't show up as real diffs. Also useful when comparing code that's been prettier-formatted differently. Most tools support this: git diff -w, diff -w on the command line, and most IDE diff views. Pro tip: use "Ignore whitespace at line ends" only for trailing whitespace, or "Ignore all whitespace" for full normalisation. The latter can hide indentation bugs in Python, where whitespace is syntactically meaningful — be cautious there. For YAML files, never ignore indentation.
How do I compare two markdown documents?
Paste both files into our Diff Checker as plain text — it'll do a line-by-line diff. For semantic comparison (where **bold** vs __bold__ doesn't show as different because both render to bold), render both to HTML first using our Markdown converter, then diff the HTML. Word-level diff is also helpful: it highlights changed words within unchanged lines, making prose edits much easier to review. Useful for blog drafts, README updates, and documentation reviews. For Git-tracked Markdown, git diff --word-diff does the same thing on the command line. We support both line-mode and word-mode in the toggle.
How do I diff two log files and find the new errors?
Logs are tricky because timestamps make every line look different. Three approaches: one, strip timestamps with a regex before comparing (our tool has a "strip timestamps" preset). Two, sort both files by message and use comm -23 sorted_new.log sorted_old.log to find lines unique to the new file. Three, if logs have unique error codes, grep ERROR both files and diff just those lines. For ongoing monitoring, real log analysis tools (Grafana Loki, Splunk, Elastic) are better fits. For ad-hoc debugging — like checking what changed between a working and broken deploy — text diff is fast and good enough.
How do I show only added or removed lines in a diff?
In our Diff Checker, use the filter buttons above the diff pane: "Added only" hides everything except green lines; "Removed only" shows just red. Useful when you want to focus on what's new versus what's gone. On the command line, diff old.txt new.txt | grep '^>' shows only added lines (or ^< for removed). For Git, git diff --stat summarises by file, and git log --diff-filter=A lists commits that added files. For large refactors with thousands of changes, filtering by added-only often surfaces the actual new behaviour quickly without wading through every code move.
How do I share a diff with a teammate via a link?
Our Diff Checker has a "Share" button that uploads the diff to a temporary, unguessable URL valid for 7 days. Paste the link in Slack, email, or a ticket — anyone with the link can see the same comparison. No login required. Diffs are encrypted at rest and auto-deleted after expiry, so there's no long-term data on our servers. For sensitive corporate code, use Git-hosted PR diffs instead, where access is controlled by your repo permissions. For quick "hey what do you think of this change?" reviews, our share link is faster than setting up a branch and PR.