A zero-dependency Go CLI that converts git diffs into styled, self-contained HTML pages.
Supports line-by-line and side-by-side views with automatic light/dark theming.
- Parse git diff output from command, file, or stdin
- Render in
lineorsidelayout - Auto light/dark theme support
- Optional file-level summary
- Output as HTML or JSON
go install github.com/garovu/gitdiffgohtml/cmd@latestOr build from source:
git clone https://github.com/garovu/gitdiffgohtml
cd gitdiffgohtml
go build -o gdgh ./cmdgdgh [flags] [-- git diff args]
| Flag | Description | Default |
|---|---|---|
-s, --style |
Output style: line, side |
line |
-cs, --colorScheme |
Color scheme: auto, dark, light |
auto |
--summary |
Show file summary | true |
-t, --title |
Page title for HTML output | "Diff to HTML" |
-f, --format |
Output format: html, json |
html |
-i, --input |
Input source: file, command, stdin |
command |
-o, --output |
Output destination: preview, stdout |
preview |
-F, --file |
Write output to file | |
-v, --version |
Show version | |
-h, --help |
Show help |
# Diff last commit and open preview in browser
gdgh
# Diff last 3 commits with rename detection
gdgh -- -M HEAD~3
# Side-by-side view, write to file
gdgh -s side -F output.html -- HEAD~1
# Read from a diff file
gdgh -i file my.diff
# Pipe from stdin, side-by-side
cat my.diff | gdgh -i stdin -s side
# Output as JSON
gdgh -f json -o stdout -- HEAD~1MIT
