Prompt Diff Comparator
Compare prompt versions and map expected A/B outputs locally
Version A
Version B
A/B output matrix
| Input | Expected A | Expected B |
|---|---|---|
Examples
Added placeholder
comparePlaceholders("Summarize the report.", "Summarize the report for {audience}."){ added: ["audience"], removed: [], shared: [] }The v2-only {audience} variable surfaces as added so the caller knows to supply it.
Brace-style equivalence
comparePlaceholders("Hello {name}", "Hello {{name}}"){ added: [], removed: [], shared: ["name"] }Single- and double-brace spellings normalize to the same variable name.
About this tool
Prompt Diff Comparator diffs two prompt versions with comparePromptVersions(versionA, versionB, rows): diffPromptLines runs a line-oriented LCS diff with stable oldLine/newLine numbers, comparePlaceholders diffs added/removed/shared placeholders, analyzePrompt reports characters, lines, chars/4 tokens, instruction counts, and placeholders, and validateABMatrix flags blank input/outputA/outputB cells.
Placeholders normalize across syntaxes: extractPlaceholders finds {var}, {{ var }}, and $VAR forms and returns one sorted unique list, so {name} and {{name}} compare as the same variable. Instruction counting is deterministic — short imperative sentences starting with verbs like summarize, explain, list, or return.
Edge behavior is well-defined: identical prompts produce an all-equal diff with zero added/removed lines, an empty v1 marks every v2 line added, empty prompts analyze to zeros, and blank matrix cells are reported as { row, column } entries without throwing.
How to use this tool
Paste both versions
Put v1 on the left and v2 on the right; the LCS diff marks equal, added, and removed lines with stable numbers.
Check placeholder drift
Read added/removed/shared to catch renamed or dropped {vars} before a template breaks in production.
Compare metrics
Use characters, estimatedTokens, and instruction counts per version to confirm the rewrite stayed in budget.
Validate the A/B matrix
Add input/outputA/outputB rows and fix any missingCells entries so every test case is runnable.
Use cases
Reviewing prompt pull requests
Show line-level additions and removals plus placeholder drift when a teammate edits a system prompt.
Catching renamed template variables
Detect a {tone} → {style} rename before the serving path passes the old variable and renders blank.
Sizing prompt rewrites
Compare per-version token and instruction counts to prove a shorter rewrite kept the same directives.
Common mistakes
Mistake:Treating {var} and {{var}} as different variables.
Fix:Both spellings extract to the same name — unify on one style for readability, not correctness.
Mistake:Ignoring blank A/B matrix cells.
Fix:Whitespace-only input/outputA/outputB counts as missing; fill or delete the row before running the comparison.
Mistake:Reading the diff as word-level.
Fix:The diff is line-oriented LCS — split long paragraphs into lines to get precise change locations.
Frequently asked questions
What does this tool do?
It diffs two prompt versions with comparePromptVersions: an LCS line diff, {var}/{{var}}/$VAR placeholder drift (added/removed/shared), per-version token and instruction metrics, plus blank-cell detection for the A/B input/output matrix.
Are {var} and {{var}} treated as different?
No. Both spellings extract to the same name, so Hello {name} versus Hello {{name}} reports zero added and zero removed with name shared.
Is my prompt data uploaded or stored?
No. Diffing, placeholder extraction, and metrics run entirely in your browser.
What does an empty v1 or a missing matrix cell mean?
An empty v1 marks every v2 line added with null oldLine numbers. A whitespace-only matrix cell reports as { row, column } in missingCells — fill it before running the comparison.
Related guides
References & standards
Related tools
Agent Tool Flowchart Builder
Design agentic tool-call DAGs with decision branches and bounded loops. Validates reachability, cycle handling, and emits clean Mermaid flowcharts — fully in your browser.
AI Agent Memory & Buffer Simulator
Compare sliding window, summary buffer, and vector memory strategies
AI API Client SDK Generator
Generate typed API client SDK files from OpenAPI specifications or cURL requests
AI Code Explainer
Explain code snippets with grounded cloud AI
AI Code Security Auditor
Scan source code for high-confidence OWASP Top 10 vulnerabilities
AI Code Translator
Translate code into idiomatic implementations in another language