Unified Diff Parser

Parse and visualise unified diff or git diff output.

Open tool

Overview

Paste a unified diff or git diff output and the parser renders it as a structured view - file by file, hunk by hunk, with added/removed lines highlighted and counts summarised at the top. Useful for inspecting a patch without applying it.

It's for code reviewers, developers stuck on a server without a graphical Git client, and anyone debugging an applied-from-email patch that's mangled. Reach for it when reviewing a generated patch, validating that a diff applies cleanly, or producing a quick summary of what a PR touches.

How it works

The parser handles the unified diff format described in diff(1) and produced by git diff. Files start with diff --git a/x b/y (in Git) or --- a/file and +++ b/file (plain unified diff), followed by hunks introduced with @@ -start,count +start,count @@. Lines beginning with + are additions, - deletions, and context.

Stats are computed per-file (additions, deletions, hunks) and across the whole patch. Binary files and rename/copy markers are recognised as Git-specific extensions.

Examples

  • A simple hunk:
    --- a/main.py
    +++ b/main.py
    @@ -1,4 +1,4 @@
    def hello():
    -    print("hi")
    +    print("hello")
         return None
    
  • Summary:
    main.py: +1, -1
    
  • Git rename:
    diff --git a/old.py b/new.py
    similarity index 100%
    rename from old.py
    rename to new.py
    
  • Binary file marker:
    Binary files a/logo.png and b/logo.png differ
    

FAQ

What's the difference between unified and context diff?

Context diff (diff -c) shows added and removed sections separately with surrounding context. Unified diff (diff -u) interleaves them, which is the format Git uses and the parser supports.

Can it apply the diff?

No - it's read-only. Apply with git apply or patch -p1 < file.diff.

Does it handle three-way diffs?

Three-way diffs (with +++, ---, and a base file) appear during merge conflicts. The parser handles the standard two-way unified format; three-way merge output needs a merge-aware tool.

What about whitespace-only changes?

They're parsed as normal additions/deletions. Pass --ignore-all-space to git diff to exclude them before parsing if you want to focus on substantive changes.

Try Unified Diff Parser

An unhandled error has occurred. Reload ×