A diff tool for Typst documents, similar to latexdiff for LaTeX.
typdiff compares two Typst source files and generates a new Typst document that visually highlights the differences — added text in blue with underline and deleted text in red with strikethrough.
Given an old document:
= Introduction
This is the old text.
- First item
- Second item
== Details
The quick brown fox jumps over the lazy dog.And a new document:
= Background
This is the new text.
- First item
- Third item
- Fourth item
== Details
The quick red fox leaps over the lazy cat.Running typdiff old.typ new.typ produces:
= #diff-deleted[Introduction]
= #diff-added[Background]
This is the #diff-deleted[old]#diff-added[new] text.
- First item
- #diff-deleted[Second]#diff-added[Third] item
- #diff-added[Fourth item]
== Details
The quick #diff-deleted[brown]#diff-added[red] fox #diff-deleted[jumps]#diff-added[leaps] over the lazy #diff-deleted[dog]#diff-added[cat].Compile the output with typst compile to get a PDF with visual diff markup.
mise 2026.9.2 or later installs the appropriate prebuilt binary for your platform from the release's signed packslip manifest, verifying the signature and the archive's digest before unpacking it.
mise use -g packslip:github.com/sou1118/typdiffReleases before v0.1.4 have no packslip manifest. To install one of them, or with an older mise, use the GitHub backend, which verifies GitHub Artifact Attestations when available:
mise use -g github:sou1118/typdiffcargo install typdiffcargo install --git https://github.com/sou1118/typdifftypdiff <OLD> <NEW> [-o <OUTPUT>]
| Argument | Description |
|---|---|
<OLD> |
Path to the old Typst file |
<NEW> |
Path to the new Typst file |
-o, --output <OUTPUT> |
Output file path (defaults to stdout) |
# Print diff to stdout
typdiff old.typ new.typ
# Save diff to a file
typdiff old.typ new.typ -o diff.typ
# Generate a PDF
typdiff old.typ new.typ -o diff.typ && typst compile diff.typ- Block-level diffing — Detects structural changes in headings, paragraphs, list items, enum items, and term list items
- Word-level diffing — Shows fine-grained changes within modified blocks
- CJK support — Character-level granularity for Chinese, Japanese, and Korean text
- Atomic blocks — Raw blocks, equations, and function calls are treated as indivisible units
- Safe output — Escapes references, labels, and special syntax in deleted content to prevent compilation errors
- Parse — Both Typst files are parsed into block-level elements (headings, paragraphs, list items, etc.) using
typst-syntax - Diff — Blocks are compared using the Patience diff algorithm, with similarity-based matching for modified regions
- Render — The diff result is rendered back to Typst source with
#diff-added[...]and#diff-deleted[...]markup
Apache-2.0