Diff Checker
Compare two texts and see differences highlighted line by line. Free online diff tool — runs entirely in your browser, no data sent to any server.
Original
Modified
Paste text into both fields above to see the diff.
How to Use the Diff Checker
Paste your original text into the left panel and your modified text into the right panel. The diff is computed automatically as you type — there is no submit button to click. Changed lines appear instantly below both panels, with green lines for additions and red lines for removals. Unchanged lines are shown without highlighting so you can scan the context around each change.
Each changed line displays its line number on the left margin, making it easy to locate the exact position in your source file. Once you have reviewed the output, use the copy button to grab the diff in unified format and paste it into a code review comment, a ticket, or a commit message. The entire comparison runs in your browser — no files are uploaded and nothing is logged.
For structured data like JSON or YAML, format both inputs with consistent indentation before pasting. You can use our JSON Formatter to format JSON with consistent indentation before diffing, which turns a wall of minified text into a meaningful line-by-line comparison. For SQL queries, our SQL Formatter can normalize whitespace and keyword casing before you compare two versions of a query.
What is a Diff?
A diff (short for difference) is a comparison between two versions of a text. It shows which lines were added, removed, or left unchanged. Diffs are used in version control systems like Git to track code changes over time.
Use Cases
- Code review — Compare two versions of a function or file before merging.
- Config changes — Spot differences between two configuration files.
- Document editing — See what changed between two drafts of a document.
- Log analysis — Compare log outputs from two runs to find discrepancies.
- API response comparison — Diff two JSON responses to catch unexpected changes.
- SQL query tuning — Compare query plans or output sets between two versions.
How the Diff Algorithm Works
This tool uses the Longest Common Subsequence (LCS) algorithm to find the minimal set of changes between two texts. LCS identifies the longest sequence of lines that appear in both versions in the same order, then marks everything else as added or removed.
The Unix diff command and Git both use variants of this approach (Git uses the Myers diff algorithm by default). The result is a compact, human-readable change summary that highlights only what actually changed.
Tips for Better Diffs
- Normalize whitespace first — Extra spaces or tabs at line endings create false differences. Trim your input if you only care about content changes.
- One logical unit per comparison — Compare a single function, config block, or paragraph at a time for cleaner output.
- Use for JSON — Format both JSON objects with consistent indentation before diffing to get meaningful line-level differences.
- Check line endings — Windows (
CRLF) and Unix (LF) line endings can produce unexpected diffs. Convert to the same format first.
Best Practices
Getting clean, actionable diffs requires a little preparation. These habits keep the output focused on real changes rather than noise:
- Sort JSON keys before diffing — JSON objects have no guaranteed key order. If two responses contain the same data but in different key order, a naive diff shows every line as changed. Sort the keys first (most formatters have a "sort keys" option) to get a meaningful comparison.
- Use for config file auditing — Before applying an infrastructure change, diff the current config against the proposed config to produce a human-readable change record for your change management process.
- Remove comments before comparing logic — If you only care whether the executable logic changed, strip inline comments first so comment edits do not obscure code changes.
- Combine with version control for pre-commit checks — Run a diff between your working file and the last committed version to self-review before committing. It catches stray debug lines and accidental deletions before they land in history.
Related Guides
- Text Diff Algorithms Explained — how LCS and Myers diff work under the hood
- The Algorithm Behind git diff — a deep dive into the Myers diff algorithm
FAQ
Is my data safe?
Yes. All comparison happens in your browser using JavaScript. No text is ever sent to a server.
What kind of diff does this tool produce?
It produces a line-by-line diff using the Longest Common Subsequence (LCS) algorithm, similar to the Unix diff command.
Can I compare code files?
Yes. Paste any text — code, prose, configs, or logs — and the tool will highlight added, removed, and unchanged lines.
Can I compare JSON?
Yes. For best results, format both JSON objects with consistent indentation before pasting. This ensures the diff highlights meaningful content changes rather than formatting differences.
What is the difference between unified and side-by-side diff?
A unified diff shows both old and new lines interleaved in a single column, prefixed with - (removed) and + (added). A side-by-side diff shows the two versions in parallel columns. This tool uses a unified format for compact, scannable output.
Is there a size limit?
The tool handles texts up to ~1MB comfortably. For very large files, consider using git diff or a desktop diff tool like Beyond Compare or Meld.
Related Articles
The Algorithm Behind git diff: How Myers Diff Works
A deep dive into the Myers diff algorithm that powers git diff — from edit graph theory to shortest edit scripts and unified diff output.
Text Diff Algorithms Explained: How Git and Diff Tools Work
Understand how text diff algorithms work, from simple line comparison to the Myers diff algorithm used in Git. Learn about LCS, edit distance, and practical applications.