Home › Developer Tools › Diff Viewer

Diff Viewer

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

  1. 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.
  2. Paste it into the box or click Open .diff / .patch. The viewer updates as soon as you paste.
  3. Pick a layout: Side by side for reviewing edits, Inline for narrow screens or long lines.
  4. Navigate with the file list on the left; type in the filter box to find a file quickly.
  5. Collapse files you have already reviewed, or turn off wrapping to see long lines unbroken.

Anatomy of a git diff

LineMeaning
diff --git a/src/app.js b/src/app.jsStart of a file in a git diff, with the old (a/) and new (b/) paths
new file mode 100644 / deleted file modeThe file was created or removed (100644 is a normal file, 100755 an executable)
similarity index 92%, rename from / rename toGit detected a rename; the percentage is how much content stayed the same
index 3f2a9c1..8b17d04 100644Abbreviated blob hashes of the old and new file contents
--- a/src/app.js / +++ b/src/app.jsOld 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 lineContext line (starts with a space), present in both versions
-removed lineOnly in the old version
+added lineOnly in the new version
\ No newline at end of fileThe previous line is the last one and has no trailing line break
Binary files a/x.png and b/x.png differA binary file changed; no line-by-line diff is possible

Useful commands for producing diffs

CommandShows
git diffUnstaged changes in your working tree
git diff --stagedChanges staged for the next commit
git diff main...featureWhat a branch changed since it split from main (like a pull request)
git show <commit>One commit's message and diff
git format-patch -3The last three commits as email-style .patch files
git diff -U10Diff with 10 lines of context instead of the default 3
git diff -MDetect renamed files (on by default in recent git)
diff -u old.txt new.txtUnified diff of two files without git
diff -ruN dirA dirBRecursive 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.

Related tools

Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.CSV Diff CheckerCompare two CSV files by key column and see added, removed and changed rows cell by cell.JSON CompareCompare two JSON documents and see every added, removed and changed path.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.Online Python CompilerRun Python 3 in your browser with input(), numpy, pandas, charts and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.Logic Gate SimulatorBuild logic circuits with AND, OR, NOT, XOR gates and flip-flops; see live outputs and truth tables.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.JMESPath TesterEvaluate JMESPath expressions against JSON live, the query language used by the AWS CLI.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.XSLT TesterRun an XSLT 1.0 stylesheet on XML in your browser and see the output as HTML, XML or text.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.
See all 53 Code Playgrounds & Testers →