Skip to main content
{/}codefunc
GuidesJuly 23, 2026 · 2 min read

Unified Diffs and Patches: Create, Summarize, and Apply Changes Cleanly

How unified diffs work, when to use a patch viewer vs text/JSON diff, and a safe browser workflow for creating and applying single-file patches.

By codefunc

diffpatchgitcode-reviewtooling

A unified diff is the lingua franca of code review: --- / +++ headers, @@ hunks, and +/- lines. Git speaks it. patch applies it. Chat tools paste it. Yet many teams still eyeball two blobs in a side-by-side editor without ever producing a shareable patch — or they paste a multi-file git diff into a tool that only understands one file and wonder why apply fails.

Bottom line: Use Text Diff for quick line noise, JSON Diff when key order should not matter, and Patch Viewer when you need a real unified patch to create, summarize, or apply.

Diff styles compared

Tool Best for Ignores key order? Produces applyable patch?
Text Diff Logs, prose, generic files N/A No (display-oriented)
JSON Diff Config / API JSON Yes No
Patch Viewer Single-file unified diffs N/A Yes

Anatomy of a unified patch

--- a/note.txt
+++ b/note.txt
@@ -1,3 +1,3 @@
 Line one
-Line two
+Line two changed
 Line three
  • Context lines (no prefix) anchor the hunk.
  • - removed, + added.
  • Apply fails when context does not match the target file.
  1. Create — paste Original and Modified into Patch Viewer (Create mode).
  2. Summarize — paste an existing patch to count additions/deletions before a review.
  3. Apply — replay a single-file patch onto Original when you trust the context.
  4. For JSON configs, run JSON Diff first so formatting-only churn does not pollute the patch story; use Text Diff when you care about exact lines.

Failure modes

Symptom Cause Fix
Apply fails Context mismatch / wrong base Recreate patch from the true original
Empty-looking patch Identical inputs Confirm Modified actually changed
Partial apply Multi-file git diff Split to one file or use git apply locally

Practical takeaway

Patches are contracts: same base, same context, same result. Keep browser patching to single-file cases. For repo-wide changes, stay in git. For API JSON, structural-diff first, then patch only if you need a transferable hunk. Start in Patch Viewer.

Sources

Try it on codefunc

Related articles

3

Search tools

Find a developer tool