Update 2017 (2 years later)

Jaybeecave mentions in the comments the tool diff2html.xyz, a diff parser and pretty html generator.


The git diff format is inspired by the diff -p unix command.
(with -p being for --show-c-function: Show which C function each change is in.)

As I explain in "Where does the excerpt in the git diff hunk header come from?", that feature ("Show which C function") has evolved to take into account other language.

This is similar to what you see in the patch field of the JSON answer when you compare two commits with the GitHub API.
That feature was introduced in December 2012

Simply use the same resource URL and send either application/vnd.github.diff or application/vnd.github.patch in the Accept header:

curl -H "Accept: application/vnd.github.diff" https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c

Result:

diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink
index 1f599cb..abaf625 100755
--- a/tmux/tmux.conf.symlink
+++ b/tmux/tmux.conf.symlink
@@ -111,6 +111,7 @@ set-option -g base-index 1
 ## enable mouse
 set-option -g mouse-select-pane on
 set-option -g mouse-select-window on
+set-option -g mouse-resize-pane on
 set-window-option -g mode-keys vi
 set-window-option -g mode-mouse on
 # set-window-option -g monitor-activity off

The format follows the classic diff unified format (also detailed here).
You can see an example in cubicdaiya/node-dtl (an dtl(diff template library) binding for node.js)

Answer from VonC on Stack Overflow
🌐
npm
npmjs.com › package › git-diff
git-diff - npm
March 9, 2018 - Returns the git diff of two strings. Latest version: 2.0.6, last published: 8 years ago. Start using git-diff in your project by running `npm i git-diff`. There are 59 other projects in the npm registry using git-diff.
      » npm install git-diff
    
Published   Mar 09, 2018
Version   2.0.6
Author   Daniel Lewis BSc
🌐
GitHub
github.com › rtfpessoa › diff2html
GitHub - rtfpessoa/diff2html: Pretty diff to html javascript library (diff2html) · GitHub
lib/ui/js/diff2html-ui-base.js - includes the wrapper of diff2html without including a highlight.js implementation. You can use it without syntax highlight or by passing your own implementation with the languages you prefer · Diff2Html can be used in various ways as listed in the distributions section.
Starred by 3.3K users
Forked by 300 users
Languages   TypeScript 88.0% | Handlebars 5.7% | CSS 4.1% | HCL 1.0% | Mustache 0.8% | JavaScript 0.4%
Top answer
1 of 1
4

Update 2017 (2 years later)

Jaybeecave mentions in the comments the tool diff2html.xyz, a diff parser and pretty html generator.


The git diff format is inspired by the diff -p unix command.
(with -p being for --show-c-function: Show which C function each change is in.)

As I explain in "Where does the excerpt in the git diff hunk header come from?", that feature ("Show which C function") has evolved to take into account other language.

This is similar to what you see in the patch field of the JSON answer when you compare two commits with the GitHub API.
That feature was introduced in December 2012

Simply use the same resource URL and send either application/vnd.github.diff or application/vnd.github.patch in the Accept header:

curl -H "Accept: application/vnd.github.diff" https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c

Result:

diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink
index 1f599cb..abaf625 100755
--- a/tmux/tmux.conf.symlink
+++ b/tmux/tmux.conf.symlink
@@ -111,6 +111,7 @@ set-option -g base-index 1
 ## enable mouse
 set-option -g mouse-select-pane on
 set-option -g mouse-select-window on
+set-option -g mouse-resize-pane on
 set-window-option -g mode-keys vi
 set-window-option -g mode-mouse on
 # set-window-option -g monitor-activity off

The format follows the classic diff unified format (also detailed here).
You can see an example in cubicdaiya/node-dtl (an dtl(diff template library) binding for node.js)

🌐
GitHub
github.com › kpdecker › jsdiff
GitHub - kpdecker/jsdiff: A javascript text differencing implementation. · GitHub
A javascript text differencing implementation. Contribute to kpdecker/jsdiff development by creating an account on GitHub.
Starred by 9.1K users
Forked by 525 users
Languages   JavaScript 64.7% | TypeScript 35.3%
🌐
Git
git-scm.com › docs › git-diff
Git - git-diff Documentation
This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.
🌐
npm
npmjs.com › package › parse-git-diff
parse-git-diff - npm
import parseGitDiff from 'parse-git-diff'; const result = parseGitDiff('... git diff ...'); console.log(result); // { // "type": "GitDiff", // "files": [ // { // "type": "AddedFile", // "chunks": [ // { // "type": "Chunk", // "toFileRange": ...
      » npm install parse-git-diff
    
Published   May 18, 2025
Version   0.0.19
🌐
diff2html
diff2html.xyz
diff2html
GraphQL Schema Diff · Detects dangerous and breaking changes in GraphQL schemas. cypress-plugin-snapshots · Plugin for snapshot tests in Cypress.io. git-explorer · Offline-first support for previewing local git repositories. edgar-monitor · A module that processes new Edgar filings and sends out notifications. Simple Git · A simple package to be able to drive GIT. jsreport ·
Author   Rodrigo Fernandes
🌐
Dustin John Pfister
dustinpfister.github.io › 2020 › 07 › 07 › git-diff
Git diff examples | Dustin John Pfister at github pages
November 1, 2021 - This module will use the git diff command with ids from a commit id lost created with the other module to get a list of files that have changed between a starting and ending index value of ids in the commit id list. So now I just need a main index.js file that will make use of this.
Find elsewhere
🌐
GitHub
github.com › danday74 › git-diff
GitHub - danday74/git-diff: NPM - Returns the git diff of two strings
NPM - Returns the git diff of two strings. Contribute to danday74/git-diff development by creating an account on GitHub.
Starred by 34 users
Forked by 11 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
Gatsby
gatsbyjs.com › plugins › gatsby-source-gitdiff
gatsby-source-gitdiff | Gatsby
November 12, 2018 - See defaultOptions.js for defaults to each option. options: { "diffFilter" : "ADM", // (string) A = Added, D = Deleted, M = Modified (fed into --diff-filter option of git-diff command) "dateFormat" : "MMM DD, YYYY - h:mm a", // (string) momentjs formatting string, would produce "Oct 08, 2018 - 12:34 am" "targetDirectory" : "src/pages", // (string) only include diff'ed files in this directory "afterCommit" : "017180a", // (string) start comparing after this commit "ignore" : { "firstCommit" : false, // (bool) ignore the first commit "files" : ["package.json"], // (string[]) file names to exclude "exts" : ["png"], // (string[]) file extensions to exclude "commits" : ["017180a"], // (string[]) hashes of commits to exclude } }
🌐
Made with Vue.js
madewithvuejs.com › git-diff-view
Git Diff View for Vue - Git Diff Component - Made with Vue.js
June 28, 2024 - "git-diff-view provides a Vue component to show git diff/file diff results, just like on a Github code review page.
🌐
jsDelivr
jsdelivr.com › package › npm › git-diff
git-diff CDN by jsDelivr - A CDN for npm and GitHub
March 9, 2018 - js · Returns the git diff of two strings · Version 2.0.6 License ISC · Keywords · diffdifferdifferencegit-diffgit-differgit-differencegit diffgit differgit differencestring-diffstring-differstring-differencestring diffstring differstring ...
Published   Aug 24, 2017
🌐
Scripter
scripter.co › git-diff-minified-js-and-css
Git diff Minified JS and CSS ❚ A Scripter's Notes
March 19, 2018 - [diff "minjs"] textconv = js-beautify cachetextconv = true [diff "mincss"] textconv = js-beautify --css cachetextconv = true · Now, in your project repo’s .gitattributes file, you need to associate files with the diff configurations set above.
🌐
npm
npmjs.com › package › gitdiff-parser
gitdiff-parser - npm
A fast and reliable git diff parser.. Latest version: 0.3.1, last published: 3 years ago. Start using gitdiff-parser in your project by running `npm i gitdiff-parser`. There are 16 other projects in the npm registry using gitdiff-parser.
      » npm install gitdiff-parser
    
Published   Mar 14, 2023
Version   0.3.1
🌐
MakerKit
makerkit.dev › snippets › staged-git-files-nodejs
Get changed files in a git repository with Node.js
December 26, 2022 - the git diff command · and Node.js · import { execSync } from 'child_process'; function getChangedFiles(extension: string = '') { const extensionFilter = extension ?
🌐
GitHub
github.com › cosmicanant › recursive-diff
GitHub - cosmicanant/recursive-diff: A JavaScript library to find diff between two JavaScript Objects. Support for Array, Number, Date and other primitive data types.
August 12, 2022 - A JavaScript library to find diff between two JavaScript Objects. Support for Array, Number, Date and other primitive data types. - cosmicanant/recursive-diff
Starred by 153 users
Forked by 21 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
GitHub
github.com › AlekseyLeshko › git-diff › blob › main › package.json
git-diff/package.json at main · AlekseyLeshko/git-diff
Get a git diff as JS object with commit comparison - AlekseyLeshko/git-diff
Author   AlekseyLeshko
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › string › myers diff algorithm
How can I calculate the diff between two strings in JavaScript? - 30 seconds of code
February 12, 2025 - const fileA = [ '20 bottles of beer on the wall', '20 bottles of beer', 'Take one down, pass it around', '19 bottles of beer on the wall' ]; const fileB = [ '19 bottles of beer on the wall', '19 bottles of beer', 'Take one down, pass it around', '18 bottles of beer on the wall' ]; const diffs = myersDiff(fileA, fileB); visualizeDiff(diffs); // 3 insertions(+), 3 deletions(-) // // -20 bottles of beer on the wall // +19 bottles of beer on the wall // -20 bottles of beer // +19 bottles of beer // Take one down, pass it around // -19 bottles of beer on the wall // +18 bottles of beer on the wall · Looks a lot like a Git diff, doesn't it?