Regex Bench › Text Compare

Text Compare and Diff Checker

Paste two versions and press Compare. The result is a line-by-line diff computed with a proper longest-common-subsequence algorithm, so unchanged blocks stay aligned rather than drifting.

Runs locally. What you paste never leaves this page.

How the comparison works

Both inputs are split into lines and compared with a longest common subsequence algorithm, the same approach that underlies the diff tools in version control. It finds the largest set of lines appearing in both inputs in the same order, then reports everything else as an addition or a removal.

The advantage over comparing line one to line one is that inserting a single line near the top does not make everything after it appear changed. The algorithm re-aligns on the next matching block, so a one-line insertion is reported as exactly that.

The ignore options

  • Ignore case treats upper and lower case as equivalent. Useful when comparing values from systems that normalise case differently.
  • Ignore whitespace collapses runs of spaces and tabs to a single space and trims the ends of lines. This is the option to reach for when one file was reindented, or when trailing whitespace differences are drowning the real changes. It also neutralises tabs-versus-spaces disagreements.
  • Ignore blank lines removes empty lines before comparing, which helps when one version has different paragraph spacing.

These affect only the comparison, never the displayed text. What you see is the original content; the options change which lines are considered equal.

Line endings

A frequent cause of a diff showing every line as changed when the files look identical is line endings. Windows uses carriage return plus line feed, while Unix and macOS use line feed alone. The invisible carriage return makes every line differ. Enabling ignore whitespace resolves it here; in a repository, the durable fix is a consistent line ending policy.

What this is good for

  • Reviewing edits to prose, where a word processor's change tracking is unavailable or has been flattened.
  • Comparing configuration between two environments to find the setting that differs.
  • Checking a paste against an original to confirm nothing was truncated or altered in transit.
  • Log comparison, especially with ignore whitespace enabled, where timestamps and padding otherwise dominate.

For structured data, a text diff is the wrong tool: two JSON documents that differ only in key order are semantically identical but textually very different. Compare those by structure instead.

Size limits

The algorithm needs memory proportional to the product of the two line counts, so very large inputs are refused rather than freezing the tab. Comparing a few thousand lines against a few thousand lines is comfortable. Beyond that, compare the relevant section, or use a command line diff which uses a smarter algorithm for very large inputs.

Questions

Why does every line show as changed when the files look the same?

Almost always line endings. Windows files end lines with carriage return plus line feed while Unix files use line feed alone, and the extra invisible character makes every line differ. Enable ignore whitespace to confirm.

Is my text uploaded?

No. The comparison runs in your browser, so both versions stay on your machine. That matters when comparing contracts, configuration or anything else confidential.

Does it compare word by word within a line?

No, this compares whole lines. A line with a single word changed is shown as one removal and one addition. Line granularity keeps large comparisons fast and readable.

Why was my comparison refused as too large?

The algorithm needs memory proportional to the product of the two line counts, so very large pairs are declined rather than freezing the page. Compare a smaller section, or use a command line diff.

Other tools