Diff Checker - Online Text Compare

Compare two texts side by side and see the differences highlighted. Free online diff tool for code, text, and configuration files.

Your data never leaves your browser Available via MCP

Paste two texts to see differences — comparison happens automatically

How to Use

  1. Paste the original text in the left panel.
  2. Paste the modified text in the right panel.
  3. Click Compare to see the differences highlighted below.
  4. Added lines appear in green, removed lines in red, and unchanged lines in gray.

Why Use a Diff Checker?

Comparing text differences is essential for code review, debugging configuration changes, tracking document revisions, and verifying data transformations. A visual diff makes it immediately clear what changed between two versions, saving time compared to manual line-by-line comparison.

Common Use Cases

  • Code review — Compare two versions of a function or file to understand what changed
  • Configuration debugging — Spot differences between working and broken config files
  • API response comparison — Compare JSON or XML responses from different endpoints
  • Document versioning — Track changes between drafts of documentation or articles
  • Database migration — Verify SQL schema differences between environments

Understanding Diff Output

The diff output uses a unified format familiar to Git users. Each line is prefixed with a symbol: + for additions, - for deletions, and a space for unchanged lines. Line numbers from both the original and modified text are shown in the gutter for easy reference.

How the Diff Algorithm Works

Under the hood, text comparison tools use the Longest Common Subsequence (LCS) algorithm. LCS finds the longest sequence of lines that appear in both texts in the same order, without requiring them to be contiguous. Everything outside the LCS is either an addition or a deletion. For example, if text A has lines [a, b, c, d, e] and text B has [a, c, e, f], the LCS is [a, c, e] — so b and d were removed, and f was added.

The classic LCS algorithm runs in O(n×m) time, where n and m are the number of lines in each text. For very large files (10,000+ lines), this can become slow. Optimized variants like the Myers diff algorithm — the same algorithm Git uses internally — improve on this by finding the shortest edit script (fewest changes) in O(n·d) time, where d is the number of differences. The fewer the changes, the faster it runs, which is ideal for real-world diffs where most lines are identical.

Diff in Development Workflows

Diff output is central to modern software development. Every git diff command, every pull request review, and every merge conflict resolution relies on comparing two text versions. Understanding how to read diff output makes you faster at:

  • Code review — Scanning additions and deletions to verify correctness and spot regressions
  • Merge conflict resolution — When Git can't auto-merge, it presents conflict markers (<<<<<<<, =======, >>>>>>>) that show both versions. Understanding the diff helps you decide which side to keep
  • Patch files — The unified diff format can be saved as a .patch file and applied to another codebase with git apply. This is how open-source contributors share changes without direct repository access
  • CI/CD pipelines — Automated checks often diff configuration files or build outputs to detect unexpected changes before deployment

Tips for Cleaner Diffs

If your diffs are noisy or hard to read, try these strategies:

  • Format before comparing — Run both texts through a formatter first to normalize indentation. A JSON diff is much cleaner when both sides use consistent 2-space indentation
  • Trim trailing whitespace — Invisible whitespace differences create confusing diff lines that look identical but are marked as changed
  • Sort keys — For JSON or YAML configs, sorting keys alphabetically eliminates diffs caused by reordering rather than actual value changes
  • Use word-level diff for prose — Line-level diff works best for code. For paragraphs of text, word-level or character-level comparison highlights exactly which words changed within a line

Related Tools

Format code before comparing with the JSON Formatter, SQL Formatter, XML Formatter, CSS Minifier, or JS Minifier. Beautify HTML for cleaner diffs. Test patterns with the Regex Tester. Normalize text case before comparing with the Text Case Converter. Count differences with the Word Counter.

Frequently Asked Questions

How does the diff algorithm work?
This tool uses a Longest Common Subsequence (LCS) algorithm to compute the minimal set of additions and deletions needed to transform the original text into the modified text. Lines are compared exactly, and the result shows which lines were added, removed, or unchanged.
Can I compare code files?
Yes. Paste any text including source code, configuration files, JSON, XML, or plain text. The tool compares line by line, making it ideal for reviewing code changes before committing.
What do the colors mean?
Green lines with a + prefix were added in the modified text. Red lines with a - prefix were removed from the original. Lines without highlighting are unchanged between both versions.
Is my data safe?
Yes. All comparison happens entirely in your browser using JavaScript. No text is sent to any server.

Code Examples

Learn how to use this tool programmatically in your favorite language.

Use this tool from AI agents. The CodeTidy MCP Server lets Claude, Cursor, and other AI agents use this tool and 46 others directly. One command: npx @codetidy/mcp

Drop file to load