String Operations

Active tool: Text Diff

Compare two pieces of text and highlight what changed.

What It Does

Compares two pieces of text and shows you exactly what changed — line by line, word by word, or character by character. Pick side-by-side for a visual comparison, inline for a git-style view, or copy out a unified diff for pasting into a code review or patch command.

How to Use

  1. Paste the Original (A) text on the left.
  2. Paste the Modified (B) text on the right.
  3. Tune the comparison: change granularity to word or character for intra-line edits, switch view mode, or ignore casing / whitespace / blank lines.
  4. Click Compute diff. The summary appears immediately and the diff view renders below it.
  5. Use Copy summary to share counts, or Copy unified diff to paste a git-style patch elsewhere.
  6. Use Swap A ↔ B to flip perspectives, or Clear to reset.

Options Explained

OptionDescription
GranularityWhole lines (default), words inside changed lines, or individual graphemes
View modeInline shows one column with +/- markers; side-by-side aligns A and B in two columns
Ignore caseTreats casing differences as equal
Ignore whitespacenone, leading-trailing, or all-whitespace (collapses every run to a single space)
Ignore blank linesDrops empty/whitespace-only lines from both sides
Normalize line endingsTreats \r\n, \r, and \n as equivalent
Show line numbersToggles line-number columns in the diff view
Context lines (export)Surrounding unchanged lines kept around each hunk in the unified-diff export

Example

Pasting Hello world into A and Hello, brave new world into B with granularity = word highlights , brave new as added inside the line.

Diff options

About Text Diff

Text Diff compares two pieces of text using the Myers diff algorithm — the same algorithm used by git diff. It finds the minimal set of insertions and deletions that turn one text into the other, then shows the result either inline (one column with +/- markers) or side-by-side (A on the left, B on the right). Granularity controls how fine the comparison is: line shows whole-line changes, while word and character highlight individual edits inside changed lines.

Comparing text accurately matters in many everyday workflows. Developers review code changes before committing. Writers and editors track revisions across drafts. Legal and compliance teams verify exactly what changed between two versions of a contract or policy. Translators check that source text has not drifted between updates. This tool covers all of those scenarios with no installation, no signup, and no upload.

Common Use Cases

  • Reviewing code or configuration changes before committing or deploying
  • Comparing two versions of a contract, policy, or other legal document
  • Tracking edits across drafts of an article, essay, or blog post
  • Verifying that translated text stays in sync with the source version
  • Spotting unauthorized or accidental changes in a configuration file
  • Generating a unified-diff patch to paste into a code review or patch command

What Is a Text Diff?

A text diff is the minimal set of insertions and deletions needed to transform one text into another. The classic algorithm for computing it — published by Eugene W. Myers in 1986 — is the same one that powers git diff, GitHub pull-request views, and most code editors. The result can be presented in several ways: inline (a single column with + and - markers, like git), side-by-side (the old version on the left, the new version on the right), or as a unified diff (a portable text format with @@ hunk headers that can be applied as a patch). Beyond whole-line comparison, finer granularities highlight which specific words or characters changed inside a modified line — useful for spotting a single typo fix in a long paragraph.

Frequently Asked Questions

What is the difference between line, word, and character mode?

Line mode reports whole lines as added or removed. Word mode additionally pairs adjacent removed/added lines and highlights the individual words that changed inside them. Character mode works the same way but at the grapheme level, so it can pinpoint a single character edit.

What is a unified diff and when should I use it?

A unified diff is the standard text format used by tools like git and the Unix patch command. Each hunk starts with a @@ -oldStart,oldLen +newStart,newLen @@ header followed by lines prefixed with + (added), - (removed), or a space (unchanged context). Use it when you want to share or apply changes outside this tool.

How do the “ignore” options affect the result?

Ignore case treats Hello and HELLO as equal. Ignore whitespace can strip leading/trailing whitespace or collapse every run of whitespace to a single space. Ignore blank lines drops empty lines from both sides before comparing. Normalize line endings treats \r\n, \r, and \n as equivalent. The original text is always shown unchanged in the diff view — only the comparison is affected.

Is there a size limit?

Inputs are capped at 1 000 000 characters or 50 000 lines per side to keep the comparison responsive. Very large diffs may truncate the on-screen view, but the unified-diff export always contains the full result.

Is my text sent to a server?

No. All processing happens locally in your browser. Your text is never transmitted or stored.

This tool processes your text entirely in your browser. No data is sent to any server, ensuring complete privacy for sensitive or confidential content.