Unified Diff Format Explained
The unified diff format is the standard output of git diff and is used by patch tools worldwide. Paste any unified diff into the viewer above to see it rendered with syntax highlighting.
Git Diff Viewer
Paste unified diff output (from git diff) and view it with syntax highlighting, line numbers, and side-by-side or inline display.
Paste a unified diff above to render it with syntax highlighting and line numbers.
What is unified diff format?
Unified diff format (also called unidiff) shows changes between two files in a compact, human-readable way. It was introduced by GNU diff and is now the default output format for git diff. Each diff starts with file headers (--- and +++ lines), followed by one or more hunks that show the actual changes with surrounding context lines.
Anatomy of a unified diff
A unified diff has several parts: (1) The diff header line starting with 'diff --git a/file b/file'. (2) File metadata lines like 'index abc1234..def5678'. (3) The old file name prefixed with '--- a/'. (4) The new file name prefixed with '+++ b/'. (5) Hunk headers like '@@ -10,7 +10,8 @@' indicating line ranges. (6) Context lines starting with a space. (7) Removed lines starting with '-'. (8) Added lines starting with '+'.
Understanding hunk headers
The hunk header @@ -10,7 +10,8 @@ means: in the old file, this hunk starts at line 10 and spans 7 lines; in the new file, it starts at line 10 and spans 8 lines. The numbers after the comma indicate the number of lines shown (context + changes). Some hunks include a function name after the closing @@ for additional context.
Frequently Asked Questions
What do the + and - symbols mean in a diff?
Lines starting with '-' (minus) were removed from the old version. Lines starting with '+' (plus) were added in the new version. Lines starting with a space are unchanged context lines shown for reference. Lines starting with '@@' are hunk headers indicating line positions.
What is the difference between unified and context diff format?
Unified diff (git diff default) shows changes inline with +/- prefixes and is more compact. Context diff (diff -c) shows old and new versions in separate blocks marked with *** and ---. Unified format is preferred for code review and version control because it is more readable and produces smaller patches.
Related Inspect Tools
AI Model Comparison
Compare GPT, Claude, Gemini, Llama, and more — pricing, context windows, capabilities, and reasoning support for 21 models
JSON Visualizer
Visualize JSON as an interactive tree — collapsible nodes, search, path copy, depth controls, and data statistics
Compression Tester
Test and compare Brotli, Gzip, and Deflate compression ratios for text content — sizes, savings, and speed
TypeScript 6.0 Migration Checker
Analyze your tsconfig.json for TS 6.0 breaking changes, deprecated options, new defaults, and get a readiness grade with fixes