Diff Checker

Our diff checker compares two texts and produces a side-by-side visual diff in milliseconds. Paste the original text on the left and the modified version on the right; the tool runs an LCS-based line diff (the same algorithm family used by GNU diff, git diff and most code review tools) and highlights every change. Added lines are green, removed lines are red, and changed lines show the per-character substring that differs. A summary line reports added / removed / changed line counts plus a similarity percentage. The tool handles plain text, source code (JavaScript, Python, Go, Java, Rust, C/C++, HTML, CSS), JSON and YAML configuration, CSV data, log files and any UTF-8 input up to a few megabytes per side. All processing runs locally in your browser using JavaScript — nothing is sent to a server, so the tool is safe for proprietary code, internal docs and confidential data. Built for developers, technical writers, editors and anyone who needs to spot what changed between two versions of text fast.

star 4.9
auto_awesome AI
New

Diff Checker calculator

lock Privacy: the diff runs entirely in your browser using JavaScript LCS — no text is uploaded to any server. Safe for proprietary code, internal docs and confidential data.

lightbulb Tips

  • Runs entirely in your browser — no text is uploaded
  • Format JSON/code identically before diffing to avoid noise
  • Use 'ignore whitespace' for reformatted-but-equivalent code
  • Side-by-side for visual review; unified for patch files
  • Same LCS algorithm as GNU diff and git diff — exact, reproducible

How to Compare Two Texts in 3 Steps: Paste, Diff, and Review Changes

content_paste

Paste Text

Paste the original text into the left box and the modified text into the right box. Plain text, code, JSON, YAML, CSV — any UTF-8 input works.

compare_arrows

Run Diff

The diff is computed instantly as you paste. Added lines appear green, removed lines red, and changed lines highlight the substring that differs.

compare

Review Changes

Read the side-by-side diff and the summary stats (added / removed / similarity %). Toggle 'ignore whitespace' if reformatted code is producing noise.

content_copy

Copy or Export

Copy the unified diff for use as a patch file or screenshot the side-by-side view to share. All processing stays in your browser — nothing is uploaded.

The Formula

Modern diff tools rely on the LCS (Longest Common Subsequence) family of algorithms — the same theoretical foundation introduced by Hunt-McIlroy at Bell Labs in 1976 and refined by Eugene Myers in 1986 (the O(ND) algorithm used by GNU diff and git). Step 1: split both texts into lines. Step 2: compute the LCS — the longest sequence of lines present in both inputs in the same order. Step 3: classify every line as 'equal' (in the LCS, unchanged), 'remove' (in linesA but not LCS), or 'add' (in linesB but not LCS). Optional step 4: for adjacent remove + add pairs on similar lines, mark as 'change' and run a sub-diff at the character level to show the substring that actually changed. Similarity = 2 × LCS length ÷ (total lines in both sides). Real-world implementations add heuristics for moved blocks, whitespace handling and large files.

diff = LCS(linesA, linesB) → ops[] = {equal | add | remove | change}

lightbulb Variables Explained

  • linesA Array of lines from the left text (the original / before version)
  • linesB Array of lines from the right text (the modified / after version)
  • LCS Longest Common Subsequence — the longest sequence of lines that appears in both inputs in the same order. Lines outside the LCS are treated as add or remove operations.
  • similarity 100 × LCS_length × 2 / (linesA.length + linesB.length). Ranges from 0% (no overlap) to 100% (identical).

tips_and_updates Pro Tips

1

Use line diff for code and config files; use character diff only for short paragraphs

2

Trim trailing whitespace before diffing — many real-world 'changes' are invisible whitespace edits

3

Set the diff to 'ignore whitespace' when comparing code that has been reformatted but not behaviourally changed

4

For JSON, format both sides first (sort keys, consistent indent) so the diff catches real changes only

5

When comparing CSV files, compare row counts and headers first; the line diff will then surface true row changes

6

Side-by-side view is best for small-to-medium changes; unified diff is more compact for large rewrites

7

Keep your text local — the calculator runs entirely in your browser, nothing is uploaded or logged

8

For very large files (>1 MB), expect 1-2 seconds of compute; the LCS algorithm is O(N*M) in the worst case

9

Word-level diff helps editors compare prose; line-level diff is what code review tools use

10

For Microsoft Word documents, export to plain text first — diff tools cannot read .docx binary structure

Compare two pieces of text, code, JSON, YAML, CSV or any plain-text input side by side — instantly, free, and entirely in your browser. The diff checker uses the same LCS-based line-diff algorithm family that GNU diff, git diff, GitHub, GitLab, Visual Studio Code and JetBrains IDEs all rely on. Paste the original on the left and the modified version on the right; the tool highlights every added line in green, every removed line in red, and every changed line with character-level substring highlighting. A summary reports added/removed/changed counts plus a similarity percentage. Built for developers reviewing code, technical writers comparing doc revisions, DevOps engineers diffing config across environments, and editors checking what an author actually changed. Below: how diff tools work, format-specific guidance for JSON/CSV/YAML/code, side-by-side vs unified views, privacy considerations, and a developer-focused comparison cheat sheet.

Diff Checker Online: Compare Text, Code, and Config Files Side by Side

The diff checker compares two pieces of text and shows exactly which lines differ. Paste the original (the 'before' version) into the left text box and the modified (the 'after' version) into the right; the tool runs an LCS-based diff and highlights every difference within milliseconds. Added lines appear green, removed lines red, changed lines show character-level highlighting on the substring that actually changed. A summary line at the top reports the count of added, removed and changed lines plus a similarity percentage. Use it for any plain-text comparison: source code, JSON config, YAML manifests, CSV exports, log files, Markdown drafts, plain prose. The tool handles UTF-8 input up to several megabytes per side without breaking. Most importantly: every byte of computation runs locally in your browser. Nothing is sent to a server, nothing is logged, nothing leaves your device — safe for proprietary code, internal documents and confidential data.

How to Compare Two Texts: 3-Step Process for Diff Checker Beginners

Step 1: Paste the original text into the left box. This is the 'before' version — the file as it existed prior to changes, the original draft, the previous config. Use Ctrl+A then Ctrl+C from any text editor or browser to grab the text, then Ctrl+V into the diff checker. Step 2: Paste the modified text into the right box. This is the 'after' version — the edited file, the new draft, the updated config. The diff is computed automatically as soon as both sides have content. Step 3: Read the result. Green lines are additions present in the right but not the left; red lines are removals present in the left but not the right; lines with character-level highlighting are 'changed' (a remove + add pair on similar content). The summary at the top gives a high-level view: added count, removed count, and a similarity percentage from 0% (no overlap) to 100% (identical). Toggle 'ignore whitespace' if the only changes are reformatting; toggle 'ignore case' if you don't care about Hello-vs-hello distinctions.

Text Compare Tool: Line-by-Line vs Character-by-Character Comparison

Diff tools work at one of three granularities: line, word, or character. Line-by-line is the universal default for code and configuration: each line is treated as a unit, and the diff identifies which whole lines were added, removed or substantively changed. This is what GNU diff, git diff, GitHub PRs and IDE diff views all show. Word-by-word (sometimes called 'word diff') splits text on whitespace boundaries — better for prose where edits often occur within sentences. Character-by-character is the finest granularity, used internally by most diff tools to highlight the exact substring that differs within a changed line. The tool above shows line diff as the primary view and character diff as the highlighting on changed lines — the same two-level approach VS Code, JetBrains and GitHub use. Use line diff for code review, word diff for prose editing, character diff only for short comparisons (single sentences, identifiers, URLs).

Code Diff Checker: Source Code Comparison for JavaScript, Python, Go, and More

Source code is the most common diff use case — every code review, every PR, every git commit involves diffing code. The diff checker handles any programming language because the LCS algorithm is language-agnostic: JavaScript, TypeScript, Python, Go, Rust, Java, Kotlin, Swift, C, C++, C#, PHP, Ruby, Scala, Elixir, Clojure, shell scripts, Dockerfiles, Terraform HCL, SQL — all work the same way. Best practice for code diffs: format both sides with the same code formatter (Prettier for JS/TS, Black for Python, gofmt for Go, rustfmt for Rust) before pasting, so that whitespace and style differences don't pollute the real semantic diff. If you can't reformat, use the 'ignore whitespace' option to skip leading/trailing whitespace differences. For diffing across language boundaries (comparing a Python implementation to a Go port, for example), the line diff still works but the similarity percentage will be misleading — the meaningful unit is structural similarity, not line overlap.

JSON Diff Checker: Compare JSON Objects, Arrays, and Configuration Files

JSON diff is one of the highest-demand use cases — comparing API responses, config files, package.json files, and structured data exports. Important pre-step: format both sides identically. Pretty-print with the same indent (typically 2 or 4 spaces) and sort object keys alphabetically. Without normalisation, a structurally-identical JSON document can produce a wildly noisy diff just because the keys are in different order. Tools to normalise: jq with the --sort-keys flag, Python's json.dumps with sort_keys=True, jsonformatter.org. For semantically-aware JSON diffing (where {a:1, b:2} and {b:2, a:1} are equal), dedicated tools like json-diff (npm), jq, or RFC 6902 JSON Patch produce better output than line diff. The line-diff tool above works well for JSON when both sides are pre-normalised; if you regularly need semantic JSON diff, consider a JSON-aware library in your stack.

YAML and CSV Diff: Compare Structured Data and Configuration Differences

YAML and CSV are line-oriented formats that diff cleanly with line-based tools — usually with less noise than JSON because YAML doesn't have braces and CSV has consistent row structure. YAML diff tips: ensure both sides use the same indentation (2 vs 4 spaces matters; YAML is whitespace-significant), the same key order convention, and the same quoting style for strings. For Kubernetes manifests, Docker Compose files and CI workflow YAML, the line diff above is the standard tool used in every code review. CSV diff tips: ensure both files use the same delimiter (comma, semicolon, tab), the same line endings (LF vs CRLF — many CSVs from Excel use CRLF), the same column order, and matching headers. For large CSVs (>10,000 rows), specialised tools like csvdiff (Aswinkarthik) or daff (paulfitz) produce structured diffs showing which row and column changed; for smaller files the line diff above is fast and simple.

How Diff Tools Work: The LCS Algorithm and Myers Diff Explained

All modern diff tools rely on the LCS (Longest Common Subsequence) family of algorithms. The original diff algorithm was published by James Hunt and Doug McIlroy at Bell Labs in 1976 — the same paper that produced the Unix 'diff' command still in use today. In 1986, Eugene Myers published 'An O(ND) Difference Algorithm and Its Variations', which optimised LCS for the common case of small differences in large inputs. Myers' algorithm runs in O((N+M)D) time where N+M is the total input size and D is the number of edits — much faster than the naïve O(N×M) for typical real-world diffs (where D is small relative to N+M). GNU diff, git diff, libxdiff (used by Mercurial, Subversion, GitHub) all implement Myers or the closely-related 'patience diff' and 'histogram diff' variants. The diff checker above uses a JavaScript LCS implementation tuned for browser performance — fast enough for inputs up to several megabytes per side.

Side by Side Diff Viewer vs Unified Diff: When to Use Each Format

There are two dominant ways to display a diff: side-by-side (split view) and unified. Side-by-side puts the original and modified versions in two columns with changes aligned horizontally — easier for human reading because you can see both versions at once and the visual grouping makes structure obvious. This is the default in IDEs (VS Code, IntelliJ), GitHub PRs (in 'split' mode), and most online diff tools. Unified diff stacks removed and added lines in a single column with '-' and '+' prefixes plus 3 lines of unchanged context above and below — more compact, scriptable (it's the patch file format that 'git apply' and 'patch' consume), and the default in command-line tools and email-based code review (Linux kernel mailing list, etc). Pick side-by-side for visual review of small-to-medium changes; pick unified for compact display of large rewrites, for copying as a patch file, or for sharing in text-only contexts (chat, email, terminal).

Compare Two Documents for Differences: Writing, Editing, and Plagiarism

Document comparison covers a wide range: tracking what an editor changed in a draft, comparing two versions of a contract, checking what was paraphrased vs copied (lightweight plagiarism detection), or auditing translation drift. Use the diff checker for any plain-text document. For Microsoft Word .docx files, export to plain text first (File > Save As > Plain Text in Word, or Format > Plain Text in LibreOffice). You'll lose formatting (bold, italics, headings) but you'll catch every text change. For PDF documents, use a PDF-to-text converter first (pdftotext from poppler-utils, or browser-based tools), then diff the extracted text. For Google Docs, use the built-in Version History (File > Version history > See version history) which shows authorship-tracked diffs natively. For long-form prose where line breaks are arbitrary, consider word-level diff tools (diff --word-diff in git) — they ignore line wrapping and surface real word-level changes.

Online Diff Checker Privacy: Why Browser-Based Comparison Beats Cloud Tools

Privacy matters when diffing proprietary code, internal documentation, financial records, customer data or any confidential text. Many online diff tools upload the input text to their server for processing — convenient but a real risk for sensitive content. The diff checker on this page is fully client-side: the LCS algorithm runs in JavaScript inside your browser, no fetch() call ever leaves your device, no log entry is created on any server. Verify this yourself by opening DevTools > Network tab and pasting text — you'll see zero outbound requests. For maximum privacy on highly sensitive content, use a local tool that never touches the network: GNU diff (preinstalled on Linux/macOS), git diff (any repository), VS Code's built-in diff, JetBrains IDEs' diff, Beyond Compare. For one-off comparisons of less-sensitive text, a verified browser-based tool like the one above gives the convenience of a web tool with the privacy of a local one.

File Comparison Tool for Developers: Code Review, Merge Conflicts, and PRs

For developers, diff is daily infrastructure — code review, PR review, merge conflict resolution, comparing config across environments, debugging 'what changed' regressions. Use git diff for tracked changes (git diff, git diff --staged, git diff main..feature, git diff HEAD~3); use the online diff checker above for ad-hoc comparisons (someone pastes a snippet in Slack, you compare an env-var dump from staging vs prod, you check a colleague's local config against your own). For merge conflict resolution, three-way diff tools (kdiff3, p4merge, VS Code's built-in three-way view) outperform two-way diff because they show the common ancestor in addition to both sides. For code review at scale, GitHub PRs, GitLab MRs and Gerrit all use the same line-based LCS diff under the hood — what you see in a PR is the same algorithm you can run locally with git diff or paste into the online tool above. The diff is reproducible across tools: same inputs always produce the same diff.

Diff Checker vs Git Diff: When to Use Each in Daily Development Work

Both produce mathematically equivalent LCS-based diffs — the underlying algorithm is the same. Use git diff when: you have files in a git repository, you want to compare commits/branches/staged changes, you need to script the diff (CI checks, pre-commit hooks), you need history-aware comparison (git log, git blame), or you're producing a patch file (git format-patch). Use an online diff checker when: you have raw text not in a repo (a snippet from chat, an API response, a config dump), you want a quick visual side-by-side without setting up a repo, you're comparing across systems where git isn't available (someone on a Chromebook, a code-review meeting), or the content is sensitive and you want a verified browser-only tool with no network calls. Both tools belong in a developer's toolkit; neither replaces the other. The online tool's killer features are zero setup and visual side-by-side; git's killer features are history awareness and ecosystem integration.

code

Embed this Diff Checker on your site

Free for any site. Copy the snippet below and paste into your HTML — no attribution required beyond the built-in credit link.

<iframe src="https://calculators.im/embed/diff-checker" width="100%" height="720" style="border:0;max-width:100%;" loading="lazy" title="Diff Checker by Calculators.im"></iframe>
<p style="font-size:12px;text-align:center;color:#64748b;margin-top:6px;">Powered by <a href="https://calculators.im/diff-checker?utm_source=embed&utm_medium=snippet&utm_campaign=diff-checker">Diff Checker</a> by Calculators.im</p>
open_in_new Preview embed Auto-resizing iframe. Mobile responsive. Works with WordPress, Ghost, Webflow, and plain HTML.

Frequently Asked Questions

sell

Tags