Diff Viewer
Paste a git diff or .patch file and read it side by side or in one column, with line numbers, added and removed lines and the changed words marked.
How to read a diff
Paste your git diff or .patch file
Paste or type your git diff or .patch file into the box, or press Try an example.
Choose the layout
Side by side for reviews, one column for narrow screens.
Read the changes
Removed lines are red, added lines green, and the changed part of a line is marked.
Worked example
This is what Diff Viewer gives for its own sample values. Open the tool above and change anything to try your own.
Unified diff or .patch file
diff --git a/src/cart.js b/src/cart.js
index 3b18e51..a9f4c2d 100644
--- a/src/cart.js
+++ b/src/cart.js
@@ -12,9 +12,11 @@ export function total(items) {
let sum = 0;
for (const item of items) {
- sum += item.price * item.qty;
+ sum += item.price * item.quantity;
}
- return sum;
+ // round to cents so the display never shows 0.30000000000000004
+ return Math.round(sum * 100) / 100;
}
...- Layout
- Side by side
| File | Change | Added | Removed |
|---|---|---|---|
| src/cart.js | modified | +4 | -3 |
When to use Diff Viewer
Someone pasted a patch in a chat or email and you want to review it in a readable layout.
You are reviewing changes from git diff in the terminal and want a side-by-side view without opening an editor.
Tips for a better Diff Viewer result
Use git diff --no-color when copying from the terminal, since color codes otherwise end up in the text.
Switch to one column on a phone or narrow window, where side by side would squeeze each line too much.
Diff Viewer: limits and what to check
Binary files are listed but not shown, since a patch only says that they changed.
Whitespace-only changes look like identical lines, so turn on visible whitespace in your editor if a line seems unchanged.
About Diff Viewer
Read a diff someone pasted in a chat, an email patch or the output of git diff in a layout that is easy on the eyes. Several files, new and deleted files, renames and binary changes are recognised, and line numbers come from the hunk headers. Lines that start with dashes inside a hunk are read correctly.
FAQs
Can I compare two pieces of text instead?
Use Text Compare for that. This tool reads diffs that already exist.
Does it work with diffs from other tools?
Any unified diff works: git diff, diff -u, GitHub and GitLab .patch and .diff links, and svn diff.
Why are changed words marked?
When a removed line and an added line pair up, the part that differs is highlighted so small edits stand out.