JSON Diff: Structural Comparison vs Text Diff for Config and Code Review
How to compare JSON structurally — key order, arrays, nested objects — and when to use JSON diff versus line-based text diff in config and API review workflows.
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
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.
| 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 |
--- a/note.txt
+++ b/note.txt
@@ -1,3 +1,3 @@
Line one
-Line two
+Line two changed
Line three
- removed, + added.| 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 |
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.
How to compare JSON structurally — key order, arrays, nested objects — and when to use JSON diff versus line-based text diff in config and API review workflows.
How to format SQL for code review clarity, where dialects disagree, and when you should not reformat production migrations or generated queries.
Why compact GraphQL queries hurt reviews, how to format selection sets consistently, and a browser workflow before you paste into Apollo or GraphiQL.
Find a developer tool