Diff Tool

Side-by-side and unified text diff β€” paste two texts and see changes highlighted instantly.

πŸ“„ Original
πŸ“ Modified
Paste text into both panels above to see the diff.

What is Text Diff Tool?

Text Diff Tool compares two texts and shows the differences highlighted line by line and character by character. It uses the Myers diff algorithm to compute the minimal edit distance between the texts, displaying additions in green, deletions in red, and unchanged lines in the original color. It supports line diff, word diff, and character diff modes.

Text diff is essential for code review, document revision tracking, and debugging configuration changes. The tool shows exactly what changed between two versions without scrolling through identical content. Word-level diff highlights the specific changed words within a modified line β€” useful when comparing paragraphs where only a few words changed. Character-level diff shows single-character changes β€” useful for comparing similar strings to find typos.

The Myers diff algorithm finds the shortest edit script (minimum insertions and deletions) to transform one text into the other. This is the same algorithm used by git diff. The output is a unified diff that shows context lines around each change, making it easy to understand the change in context without seeing the entire file.

How to Use

  1. Paste the original text in the left panel and the modified text in the right panel.
  2. Select diff mode: 'Line' shows whole-line changes, 'Word' highlights changed words within lines, 'Character' shows individual character changes.
  3. Use the 'Context lines' setting to control how many unchanged lines are shown around each change.
  4. Click 'Swap' to reverse original and modified if you pasted them in the wrong order.
  5. Use 'Copy diff' to export the unified diff format for use in version control systems.

Examples

Comparing two versions of a config file

Result: Line diff shows which settings were added (green) or removed (red) between the two versions

Comparing two paragraphs of text

Result: Word diff highlights the specific words that changed within each sentence, while keeping the surrounding context

Catching a typo between two code strings

Result: Character diff highlights the exact character that differs β€” useful when visually similar strings (e.g., 0 vs O, 1 vs l) are hard to spot

Frequently Asked Questions

What is a unified diff format?

Unified diff shows changes with context lines (marked with a space), deleted lines (marked with -), and added lines (marked with +). A hunk header @@ -start,count +start,count @@ shows the line range in each file. This is the format used by git diff and patch commands.

What is the difference between line diff and word diff?

Line diff marks entire lines as added or deleted if any part of the line changed. Word diff compares within lines and marks only the specific words or tokens that changed. Word diff is more precise for prose; line diff is more natural for code.

What does edit distance mean?

Edit distance (Levenshtein distance) is the minimum number of insertions, deletions, or substitutions needed to transform one string into another. The Myers diff algorithm finds the minimum edit script in terms of insertions and deletions (no substitutions β€” a substitution is a delete + insert).

Can I diff binary files?

This tool compares text files only. Binary diff requires specialized tools (e.g., hexdiff, xxd | diff). For image comparison, use specialized image diff tools that highlight pixel differences.

What is a merge conflict and how does diff help?

A merge conflict occurs when two branches modify the same lines differently. Git shows both versions with conflict markers. Pasting each version into the two panels of this tool helps you understand exactly what each branch changed so you can resolve the conflict correctly.

Related Tools