1. Home
  2. Developer tools
  3. Patch File Viewer

Patch File Viewer

Mailing lists, pull requests and bug reports pass changes around as patches. Paste one and read it as a readable diff, with line numbers, files and totals, without applying it to anything.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Patch File Viewer

  1. Paste the diff or open a patch file.
  2. Read the files and the coloured lines.
  3. Check the added and removed totals.

Features

  • Reads git diff, git show, git format-patch and diff -u
  • Old and new line numbers for each line
  • Added, deleted, renamed and binary files recognised
  • Per-file and total counts
  • Hunk headers kept
  • Nothing is applied or uploaded

Supported formats

Input

  • Diff
  • Patch file

You get

  • Coloured diff

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Patch File Viewer is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • It reads text patches only; binary patches show the file but no lines.
  • The patch is shown, not applied or checked against any file.

Guide

Reading unified diffs and patch files

A patch is a text file that describes the difference between two versions of some files. Mailing lists use them, pull requests are built from them, and bug reports contain them. In plain text a diff is hard to read once it has more than a few lines, because the signs and line counts blur together. This viewer lays one out with the old and new line numbers and a colour for each kind of line.

The shape of a unified diff

The unified format begins each file with two header lines, — for the old file and +++ for the new one. Then come hunks, each starting with a header like @@ -1,5 +1,6 @@ followed by the lines of the hunk. A line starting with a space is context, unchanged; a minus marks a line removed from the old file, a plus a line added in the new one. Git adds a line starting with diff –git before each file and extended headers such as index, new file mode, deleted file mode and rename from.

The hunk header

The numbers in @@ -a,b +c,d @@ say where the hunk applies. The old file’s part starts at line a and spans b lines; the new file’s part starts at line c and spans d lines. If the count is left out, it is 1. The viewer shows the header as written and uses the numbers to count lines on each side, which is how it prints two columns of line numbers. A mismatch between the counts and the lines that follow is an error, since a patch tool would reject the same file.

Statuses and totals

The page marks each file as modified, new file, deleted, renamed or binary. A new file has an empty old side and a deleted file an empty new side. A rename can be pure, with no hunks, so the viewer says that no lines are shown. Binary changes, which git summarises in one line, are listed without content. At the top you see the number of files and the totals of added and removed lines.

Pasted patches

Patches copied from a web page or an email often lose trailing spaces, so a blank context line, which should be a single space, becomes an empty line and no longer matches the hunk counts. The viewer detects this inside a hunk and puts the space back, so a patch that was damaged only in that way is still read. It does not repair other changes, such as text that was wrapped into two lines.

A worked example

The Sample button loads a two-file patch. The first file, src/greet.js, is modified: the hunk @@ -1,5 +1,6 @@ removes the line returning “Hello “ + name, adds two lines with a cleaning step and a new return, and replaces the export line, for +3 and −2. The second, old.txt, is deleted and its hunk @@ -1,2 +0,0 @@ removes two lines. The summary shows 2 files, 3 lines added and 4 lines removed. Context lines carry both an old and a new number, removed lines only an old one and added lines only a new one.

Limits

The page displays patches; it does not apply, reverse or check them against files, and it does not do word-level or intra-line highlighting. Combined diffs from merge commits are not supported. Very large patches are shown in full and can be slow to render. Binary patches in git’s encoded form show the file name only. To compare two texts and get a diff, the Diff Checker is the tool for that job.

Checked against the current version of the Patch File Viewer on .

Frequently asked questions

What do the numbers in @@ -12,7 +12,9 @@ mean?

The hunk starts at line 12 of the old file and covers 7 lines there, and starts at line 12 of the new file and covers 9 lines. So the change adds net two lines. A count of 0 means that side is empty, as when a file is created or deleted.

Why does the viewer say the hunk contained an invalid line?

The header promises a number of lines and the text has more or fewer, usually because the patch was edited, wrapped by an email program or truncated when it was copied. Check that no lines were joined or cut and that blank lines still have their leading space.

What do the numbers in @@ -1,7 +1,9 @@ mean?

The hunk starts at line 1 of the old file and covers 7 lines, and starts at line 1 of the new file and covers 9. Two more lines were added than removed.

Can it apply the patch?

No. It is a viewer. To compare two texts yourself, use the Diff Checker.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.