Paste the output of git diff, git show or diff -u, or open a .diff or .patch file, and read it like a code review: files listed on the left, changes side by side or inline, with the exact words that changed highlighted.
Last updated:
Advertisement
Advertisement
How to use the Diff Viewer
Get a diff: run git diff, git show <commit> or diff -u old new, or download a .patch or .diff file from a pull request.
Paste it into the box or click Open .diff / .patch. The viewer updates as soon as you paste.
Pick a layout: Side by side for reviewing edits, Inline for narrow screens or long lines.
Navigate with the file list on the left; type in the filter box to find a file quickly.
Collapse files you have already reviewed, or turn off wrapping to see long lines unbroken.
Anatomy of a git diff
Line
Meaning
diff --git a/src/app.js b/src/app.js
Start of a file in a git diff, with the old (a/) and new (b/) paths
new file mode 100644 / deleted file mode
The file was created or removed (100644 is a normal file, 100755 an executable)
similarity index 92%, rename from / rename to
Git detected a rename; the percentage is how much content stayed the same
index 3f2a9c1..8b17d04 100644
Abbreviated blob hashes of the old and new file contents
--- a/src/app.js / +++ b/src/app.js
Old and new file names; /dev/null means the file did not exist
@@ -12,7 +12,9 @@ function load()
Hunk header: old start,count and new start,count, then optional context
unchanged line
Context line (starts with a space), present in both versions
-removed line
Only in the old version
+added line
Only in the new version
\ No newline at end of file
The previous line is the last one and has no trailing line break
Binary files a/x.png and b/x.png differ
A binary file changed; no line-by-line diff is possible
Useful commands for producing diffs
Command
Shows
git diff
Unstaged changes in your working tree
git diff --staged
Changes staged for the next commit
git diff main...feature
What a branch changed since it split from main (like a pull request)
git show <commit>
One commit's message and diff
git format-patch -3
The last three commits as email-style .patch files
git diff -U10
Diff with 10 lines of context instead of the default 3
git diff -M
Detect renamed files (on by default in recent git)
diff -u old.txt new.txt
Unified diff of two files without git
diff -ruN dirA dirB
Recursive unified diff of two folders, including new files
Tips for reviewing a patch
Start with the summary and the file list: a large number of deletions in an unexpected file is often the first sign of a mistake.
Word highlighting makes small edits stand out, such as a changed number, operator or variable name inside an otherwise identical line.
Renamed files with no content changes show only a note, so moves do not hide real edits.
If whitespace-only changes clutter a review, regenerate the diff with git diff -w to ignore them.
To apply a patch you have reviewed, use git apply changes.diff (working tree) or git am file.patch (commits from format-patch).
Frequently asked questions
What is a unified diff?
A unified diff is the standard text format for describing changes between two versions of files. Each file starts with --- (old path) and +++ (new path) lines, followed by hunks that begin with a header such as @@ -12,7 +12,9 @@. Inside a hunk, lines starting with a space are unchanged context, - marks removed lines and + marks added lines. git diff, diff -u and most code review tools use this format.
How do I read the @@ -12,7 +12,9 @@ line?
It is the hunk header. -12,7 means the hunk covers 7 lines starting at line 12 of the old file, and +12,9 means 9 lines starting at line 12 of the new file. Any text after the second @@ is a hint about the surrounding function or section. This viewer turns those numbers into real line numbers next to every line.
How do I create a diff file from git?
Run git diff > changes.diff for uncommitted changes, git diff main...feature > feature.diff for a branch, or git format-patch -1 HEAD to write the last commit as a .patch file. On GitHub you can also add .diff or .patch to the end of a pull request or commit URL to download it.
What does "No newline at end of file" mean?
The marker \ No newline at end of file tells you that the line above it is the last line of the file and has no line break after it. It often appears when an editor adds or removes the final newline, which shows up as a change to the last line even if no visible text changed.
What is the difference between side-by-side and inline view?
Side by side puts the old version on the left and the new version on the right, lining up removed and added lines so you can compare them directly. Inline (also called unified) shows removed lines in red followed by added lines in green in a single column, which works better on small screens and for very long lines.
Can it compare two files that are not in diff format?
This tool displays an existing diff. To compare two pieces of text or code that you paste separately, use the Code Diff Checker, which computes the differences for you and can then show them the same way.
Is my code uploaded?
No. The diff is parsed and rendered by JavaScript in your browser. Nothing is sent to a server, so it is safe to view patches from private repositories.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.