Text Diff & Compare

A text diff compares two pieces of text and highlights additions, deletions, and unchanged sections. Line diff marks entire changed lines; character diff highlights individual character changes within lines. The Longest Common Subsequence (LCS) algorithm finds the maximum matching content, then marks everything else as added or removed. Used for code review, document version comparison, and configuration auditing.

Compare two pieces of text side by side and see exactly what changed. Line-by-line or character-by-character diff with color highlighting. Supports ignore case and trim whitespace options.

Works OfflineDark ModeNo Ads

Presets

Options

Original Text

Modified Text

How to Use

  1. 1

    Enter original text

    Paste or type the original text in the left panel. Or click a preset to load example text pairs.

  2. 2

    Enter modified text

    Paste or type the changed text in the right panel. The diff calculates automatically.

  3. 3

    Choose diff mode

    Select Line Diff for line-by-line comparison or Character Diff for character-level detail. Toggle Ignore Case or Trim Whitespace as needed.

  4. 4

    Review the differences

    Added text appears in green with +, removed text in red with -. Statistics show total added, removed, and unchanged counts.

Frequently Asked Questions

What is a text diff?
A text diff (difference) compares two pieces of text and highlights what changed between them. Added text appears in green, removed text in red, and unchanged text stays normal. Diff tools are essential for code review, document revision tracking, and verifying configuration changes.
What is the difference between line diff and character diff?
Line diff compares text line by line — if any character on a line changed, the whole line is marked as removed (old version) and added (new version). Character diff compares character by character within lines, showing exactly which characters were added, removed, or changed. Use line diff for code; character diff for prose.
How does the diff algorithm work?
Text diff uses the Longest Common Subsequence (LCS) algorithm. It finds the longest sequence of lines (or characters) that appear in both texts in the same order, then marks everything else as additions or deletions. This is the same algorithm used by git diff and the Unix diff command.
What does ignore case mean in text comparison?
Ignore case treats uppercase and lowercase letters as identical during comparison. "Hello" and "hello" would be considered the same. This is useful when comparing text where capitalization differences are not meaningful, such as configuration files or data exports.
What does trim whitespace mean?
Trim whitespace removes leading and trailing spaces and tabs from each line before comparing. This ignores indentation differences — useful when comparing code reformatted with different indent styles (tabs vs. spaces, 2-space vs. 4-space) or text copied from different sources.
Can I use this to compare code?
Yes. This tool works for any plain text including code, configuration files, JSON, XML, CSV, and Markdown. For code-specific features like syntax highlighting, try the Diff Checker tool. This Text Diff tool is optimized for comparing any text with options for case sensitivity and whitespace handling.

Related Tools