# Base64 diff

Paste two Base64 or Base64url strings and see whether the decoded payloads really differ: first differing offset, hex dump, byte ranges, sha256 — all in your browser.

## Run it

- **CLI:** `gizza tool base64-diff "SGVsbG8gd29ybGQh" 'right=SGVsbG8gV29ybGQh'`
- **Web:** https://gizza.ai/tools/base64-diff/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/base64-diff/tool.json

## Inputs

- `left` — First Base64 (baseline / old) _(field)_
- `right` — Second Base64 (candidate / new) _(field)_
- `alphabet` — Alphabet _(field)_
- `strict` — Strict RFC 4648 (reject whitespace and bad padding) _(field)_
- `align` — Alignment _(field)_
- `output` — Output _(field)_
- `bytes_per_row` — Hex dump width (bytes per row, 4-32) _(field)_
- `context_rows` — Context kept around a change (rows / lines, 0-64) _(field)_

## Output

- Byte diff (text)

## Query parameters

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

- `left` — First Base64 (baseline / old)
- `right` — Second Base64 (candidate / new)
- `alphabet` — Alphabet
- `strict` — Strict RFC 4648 (reject whitespace and bad padding)
- `align` — Alignment
- `output` — Output
- `bytes_per_row` — Hex dump width (bytes per row, 4-32)
- `context_rows` — Context kept around a change (rows / lines, 0-64)

Example: `https://gizza.ai/tools/base64-diff/?left=SGVsbG8gd29ybGQh&right=SGVsbG8gV29ybGQh&alphabet=auto&strict=true&align=offset&output=report&bytes_per_row=8&context_rows=2`

---

## Compare Base64 by payload, not by spelling

Base64 strings are wrappers around bytes. Padding, line wrapping, data-URI prefixes and the
standard (`+` and `/`) versus URL-safe (`-` and `_`) alphabets can make two encodings look
unrelated even when they decode to the same payload. This tool decodes both sides first, then
compares the underlying bytes.

Use it when a token, attachment, signed blob or encoded API field changed and you need to know
whether the payload changed too. The report names the first differing offset, total differing
bytes, size delta, SHA-256 for each side and compact byte ranges with both hex and printable text.
For text payloads, switch to **Unified text diff**; for binary payloads, use the side-by-side
hexdump.

Everything runs locally in your browser through WebAssembly. The Base64 strings are never
uploaded anywhere.

## Worked example

Compare `SGVsbG8gd29ybGQh` (`Hello world!`) with `SGVsbG8gV29ybGQh` (`Hello World!`) and choose
**Readable summary**:

```text
Payloads differ: both 12 bytes. First difference at offset 0x0006 (6).
1 byte differs across 1 range.
@ 0x0006 (1 byte) changed: 77 |w| -> 57 |W|
```

The encoded strings differ in several characters, but the decoded payload differs by exactly one
byte: lowercase `w` (`0x77`) became uppercase `W` (`0x57`).

## Useful output modes

* **Full JSON report** — best for automation: decoded sizes, detected payload type, SHA-256 hashes,
  alphabet/padding notes and machine-readable diff ranges.
* **Readable summary** — a short verdict plus one line per changed/added/removed byte range.
* **Side-by-side hex dump** — classic hex + ASCII rows with changed rows marked by `*`.
* **Unified text diff** — decodes both payloads as UTF-8 and shows line-level `+` / `-` changes.

## Limits and edge cases

* Each input is capped at **4 MiB of Base64 text** (roughly 3 MiB decoded).
* Lenient mode repairs missing padding, ignores whitespace/line wrapping and strips a leading
  `data:...;base64,` prefix. Turn on **Strict RFC 4648** to reject those instead.
* `alphabet=auto` detects the alphabet per side and rejects a single side that mixes standard and
  URL-safe characters.
* `align=shift` trims the common prefix and suffix so one inserted byte is reported as an
  insertion; `align=offset` compares byte `i` with byte `i`, which is clearer for fixed-layout data.
* Very large text diffs fall back to a positional comparison rather than building an expensive
  line-matching table.

## FAQ

<details>
<summary>Why not just compare the Base64 strings directly?</summary>

String comparison reports encoding noise: padding, wrapped lines, URL-safe alphabets and data-URI
prefixes all change the text without changing the bytes. This tool normalises by decoding first, so
the result answers the payload question.

</details>

<details>
<summary>Can it compare Base64url tokens?</summary>

Yes. Leave **Alphabet** on automatic detection for most cases, or choose **Base64url** when you want
to force RFC 4648 URL-safe decoding. Automatic mode detects each side independently but rejects a
single input that mixes the two alphabets.

</details>

<details>
<summary>What does shift-aware alignment do?</summary>

Offset alignment compares byte 10 with byte 10, byte 11 with byte 11, and so on. If one byte was
inserted near the front, every later byte appears different. Shift-aware alignment trims the common
prefix and suffix first, so that case is reported as one insertion.

</details>

<details>
<summary>When should I use the text output?</summary>

Use **Unified text diff** only when the decoded bytes are UTF-8 text, such as a Base64-encoded JSON
or config file. Binary payloads are rejected with a message pointing you to the hexdump output.

</details>

## Related tools

- [Base Decoder](https://gizza.ai/tools/base-decoder/): Auto-detect and decode Base16, Base32, Base45, Base58, Base64, and Base85 text, including nested layers, locally in your browser.
- [Base32 Encoder / Decoder](https://gizza.ai/tools/base32-codec/): Free Base32 encoder and decoder in your browser — RFC 4648, base32hex, Crockford and z-base-32 variants, hex byte I/O, optional padding. Private, no sign-up.
- [Base58 Encoder / Decoder](https://gizza.ai/tools/base58-codec/): Encode text or bytes to Base58 and decode Base58 back in your browser — Bitcoin/IPFS, Ripple (XRP) and Flickr alphabets, hex I/O. Free, private, no sign-up.
- [Base62 Encoder / Decoder](https://gizza.ai/tools/base62-codec/): Encode text, hex bytes, or numbers to Base62 (0-9A-Za-z) and decode back — URL-safe, no padding, arbitrary-precision numbers. Free, private, in your browser.
- [Base85 Encoder / Decoder](https://gizza.ai/tools/base85-codec/): Encode text or hex bytes to Base85 and decode Base85 back. Supports Ascii85, ZeroMQ Z85, and RFC 1924 variants with optional Adobe framing. Free, private, browser-local.
