# Diff Viewer

Render a pasted unified diff as inline text, side-by-side columns, a stat summary, or structured JSON — private and browser-only.

## Run it

- **CLI:** `gizza tool diff-viewer 'diff --git a/src/main.rs b/src/main.rs
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
 fn main() {
-    println!("hi");
+    println!("hello");
+    println!("world");
 }'`
- **Web:** https://gizza.ai/tools/diff-viewer/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/diff-viewer/tool.json

## Inputs

- `diff` — Unified diff _(field)_
- `view` — View _(field)_
- `ignore_whitespace` — Ignore whitespace-only changes _(field)_

## Output

- Rendered diff (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `diff` — Unified diff
- `view` — View
- `ignore_whitespace` — Ignore whitespace-only changes

Example: `https://gizza.ai/tools/diff-viewer/?diff=diff%20--git%20a%2Fsrc%2Fmain.rs%20b%2Fsrc%2Fmain.rs%0A---%20a%2Fsrc%2Fmain.rs%0A%2B%2B%2B%20b%2Fsrc%2Fmain.rs%0A%40%40%20-1%2C3%20%2B1%2C4%20%40%40%0A%20fn%20main%28%29%20%7B%0A-%20%20%20%20println%21%28%22hi%22%29%3B%0A%2B%20%20%20%20println%21%28%22hello%22%29%3B%0A%2B%20%20%20%20println%21%28%22world%22%29%3B%0A%20%7D&view=inline&ignore_whitespace=true`

---

## About this tool

The **diff viewer** turns a pasted unified diff into a readable review artifact. It accepts output from `git diff`, `diff -u`, or a `.patch` file and parses the patch into files, hunks, line numbers, additions, deletions, renames, binary-file markers, and file-level stats.

Choose the view that fits your workflow:

- **Inline** keeps the familiar unified diff shape, but adds a concise summary and per-file banners.
- **Side-by-side** aligns old and new lines in two text columns, so replacements are easy to scan.
- **Stats** produces a compact `git diff --stat` style table with plus/minus bars and totals.
- **JSON** returns the parsed structure for scripts, review bots, dashboards, or downstream analysis.

Enable **ignore whitespace-only changes** when a patch is mostly indentation or formatting noise. Matching delete/add pairs that are identical after whitespace normalization become unchanged context and stop counting toward the totals. Everything runs locally in the browser; your patch is not uploaded.

## FAQ

<details>
<summary>Does this compare two separate text files?</summary>

No. This tool views an already-computed unified diff — for example the output of `git diff`, `diff -u old new`, or a `.patch` file. Use a separate text-diff/comparison tool when you need to generate the diff from two inputs.

</details>

<details>
<summary>What diff formats are supported?</summary>

It supports common unified diff syntax: `diff --git` headers, `---`/`+++` file headers, `@@` hunk headers, context/add/delete lines, new and deleted files, renames, binary-file markers, and hunk section headings. It is intentionally lenient about metadata lines such as `index` and file modes.

</details>

<details>
<summary>How does the side-by-side view align replacements?</summary>

Within each hunk, consecutive deleted and added lines are paired row by row. Changed pairs use a `~` marker on both sides, pure deletions use `<` on the old side, pure additions use `>` on the new side, and context lines show the same content on both sides.

</details>

<details>
<summary>What does ignore whitespace-only changes do?</summary>

When enabled, a deleted line followed by an added line with the same words after whitespace normalization is folded into a single context line. That hides indentation-only churn from the rendered output and removes it from the add/delete totals. Real content changes are still shown.

</details>

<details>
<summary>Is the patch uploaded or stored?</summary>

No. The parser is compiled to WebAssembly and runs in your browser tab. The pasted diff is processed locally and disappears when you close the page.

</details>

## Related tools

- [Extract Action Items from Meeting Notes](https://gizza.ai/tools/action-item-extractor/): Extract action items, owners, and decisions from meeting notes or daily notes with deterministic rules. Markdown checklist or JSON, private in-browser.
- [Add Line Numbers](https://gizza.ai/tools/add-line-numbers/): Add line numbers to every line of text online, like nl or cat -n — custom start, step, separator, and alignment. Free and private, runs in your browser.
- [ANSI Log Renderer](https://gizza.ai/tools/ansi-log-renderer/): Paste ANSI-colored terminal output or CI logs and render them as HTML, or strip escape codes to plain text. Handles 16-color, 256-color, and truecolor SGR codes.
- [Rust AST Diff](https://gizza.ai/tools/ast-diff/): Compare two Rust source snippets structurally. The tool parses both files, canonicalizes their ASTs, and ignores formatting, whitespace, and comments.
- [Bulk Artifact Extractor](https://gizza.ai/tools/bulk-artifact-extractor/): Scan pasted text for emails, URLs, IPs, domains, phones, Bitcoin addresses, and Luhn-valid card numbers with offsets and context.
