Compares versions of an LLM prompt: a line, word or character diff, a word frequency change, the estimated token and cost impact on a model, and Markdown output for pull request comments.
npm install -g @v0idd0/promptdiffOr run it once without installing: npx @v0idd0/promptdiff --help. Needs Node.js 18 or newer. No dependencies.
demo/v1.txt is an old prompt and demo/v2.txt the new one. Show the line diff. Output from a real run on 2026-11-26:
$ promptdiff demo/v1.txt demo/v2.txt
--- demo/v1.txt
+++ demo/v2.txt
- You are a support assistant.
- Answer in two short paragraphs.
- Never promise a delivery date.
+ You are a support assistant for an online shop.
+ Answer in one short paragraph.
+ Never promise a delivery date you cannot check.
+ Quote the order number.
// 37% similar · +15 -4 · Δ+15 tokens (estimate)Show stats and the estimated cost impact for 1000 calls a month:
$ promptdiff demo/v1.txt demo/v2.txt --stats --tokens --model claude-sonnet-5-5 --calls 1000
promptdiff stats
────────────────────────────────────────────────────────────
Before: 15 words · 92 chars · ~24 tokens
After: 26 words · 151 chars · ~39 tokens
Delta: +11 words · +59 chars · +15 tokens
Added: +15
Removed: -4
Unchanged: 11
Similarity: 37%
promptdiff token impact on claude-sonnet-5-5 (estimated tokens, prices as of 2026-11-26)
────────────────────────────────────────────────────────────
Tokens before: 24
Tokens after: 39
Delta: +15 tokens
Input cost/call before: $0.000048
Input cost/call after: $0.000078
Delta per call (input): +$0.000030
Monthly @ 1000 calls: +$0.0300Print the diff as a Markdown block for a pull request:
$ promptdiff demo/v1.txt demo/v2.txt --format markdown
```diff
--- demo/v1.txt
+++ demo/v2.txt
- You are a support assistant.
- Answer in two short paragraphs.
- Never promise a delivery date.
+ You are a support assistant for an online shop.
+ Answer in one short paragraph.
+ Never promise a delivery date you cannot check.
+ Quote the order number.
// 37% similar · +15 -4 · Δ+15 tokens (estimate)
## Usage
```text
promptdiff: compare versions of an LLM prompt.
Token counts are estimates, not exact. Prices as of 2026-11-26.
Usage:
promptdiff <file1> <file2> [<file3> ...] [options]
promptdiff -t "old prompt" "new prompt"
cat new.md | promptdiff old.md - (dash = stdin)
Options:
-f, --format <fmt> Output format: unified (default), inline, side, markdown
-t, --text Compare text strings directly (not files)
-s, --stats Stats only (word/char/token delta + similarity)
--char Character-level diff (for short prompts)
--freq Show word-frequency delta (what terms gained/lost)
--freq-top <n> How many frequency rows to print (default: 15)
--freq-min <n> Minimum word length to track (default: 3)
--tokens Show token impact and input cost estimate
-m, --model <model> Model for token impact math (default: claude)
--calls <n> Monthly call volume for cost projection (default: 100)
--json Emit JSON (machine-readable)
--no-color Disable colored output
-w, --width <n> Side-by-side column width (default: 40)
-o, --output <file> Save diff to file
-h, --help Show this help
-V, --version Show version
Formats:
unified Line-by-line like git diff (default)
inline Changes mixed in with the prose as [+added] [-removed]
side Side-by-side columns
markdown Fenced ```diff block for PR comments
Examples:
promptdiff v1.txt v2.txt
promptdiff v1.txt v2.txt --format markdown -o pr-comment.md
promptdiff prompt-old.md prompt-new.md --tokens --model claude-opus-5-5
promptdiff short-a.txt short-b.txt --char
promptdiff v1.md v2.md --freq --freq-top 10
promptdiff v1.md v2.md v3.md v4.md --stats # multi-version timeline
promptdiff -t "You are a helpful assistant" "You are a rogue assistant"
promptdiff v1.txt v2.txt --json | jq '.pairs[0].stats.delta.tokens'
promptdiff <(git show HEAD~1:prompt.txt) prompt.txt
Docs and issues: https://github.com/voidd0/promptdiff
Token counts are estimates. promptdiff does not use a tokenizer. It blends a word count (times 1.3), a punctuation count and characters divided by 3.8, then rounds up. On 20 JavaScript and Markdown files from the ctxstuff repository this gave between 0% and 31% more than the tiktoken cl100k_base count (13% more on average) on 2026-11-26. It was not compared with the tokenizers of Claude or other models. The cost shown is the input price only, times the estimated tokens, so the monthly figure is a rough guide.
Prices. The model table is the file src/prices.json. Each entry has the input and output price in USD per 1M tokens and a checked date. Entries dated 2026-11-26 were read on that day from the provider pages: Anthropic, OpenAI, Google, xAI, DeepSeek and Alibaba Cloud (international prices). 20 entries for Mistral, Cohere, Amazon Nova and Meta Llama keep their old date of 2026-04-22: they were not refreshed and may be out of date, because the provider pages did not give a clear per-token price list: Mistral's two pages disagreed and stated no unit, Cohere lists only legacy models, the Amazon Nova tables could not be read and Meta lists no per-token prices. Models a provider no longer lists were removed. Where a provider has tiers (long prompts, peak hours, dated price changes) the table holds the base price and the tier is written in the entry's note. The table has 99 models. The context window is stored only where the price page states it, otherwise it shows as n/a.
MIT, see LICENSE.
Made by vøiddo. More command line tools: voiddo.com/packages. We also run data scrapers for job boards, shops and ad libraries: voiddo.com/scrapers.