Text Diff

Compute a unified diff between two blocks of text (line-based).

Monitor this automatically

NetTests can run this check on a schedule, preserve historical results, compare changes over time, and alert you the moment something breaks.

Start monitoring free → See all monitoring products

Frequently Asked Questions

What is a unified diff?

A unified diff shows changes between two texts in a compact format: lines preceded by - were removed, lines with + were added, and lines with no prefix are unchanged context. The @@ -1,4 +1,5 @@ hunk header shows which lines in the original (-) and new (+) text are affected. This is the standard format used by Git and most version control systems.

What is this useful for?

Comparing configuration files before and after a change, reviewing edits to documents or scripts, generating patch files, spotting unintended whitespace changes, and verifying that a processed/transformed version of text matches expectations. It's also helpful for comparing API responses or log snippets.

Is the diff case-sensitive?

Yes — by default, the comparison is case-sensitive and whitespace-significant. A line reading Hello differs from hello. Trailing whitespace differences are also flagged. Normalize your input (trim, lowercase) before comparing if you only care about content, not formatting.