Prompt diff with cost
Compare two versions of a prompt or a request's messages word by word, and see what the change does to tokens, cost per request and per month, and the cache.
What it does
A small edit to a prompt that runs thousands of times a day can move the monthly bill more than it looks. Paste the version in use and the version you are considering. The Prompt Diff shows what changed — word by word or line by line — and, at the top, what the change does:
- Tokens — before, after and the difference, with the way they were counted written beside them.
- Cost per request and per month — both versions priced on the model you pick, at the output and the number of requests a day you enter. A month is 30 days.
- The prompt cache — where the first change is, and how much of the old version a cache entry could still serve.
Compare plain text, or two requests: a request body in Chat Completions, Responses, Anthropic Messages or Gemini format, read the way the other request tools read it. Try it: reworded instructions, a date added at the start of a Claude prompt, or a few-shot example added to a request.
Everything runs in your browser. Nothing you paste is sent anywhere.
How it computes
The comparison is a longest-common-subsequence diff, in the browser, with a fixed memory ceiling: a table of at most a million cells, after the shared beginning and end are set aside. Word mode compares words as your browser's Unicode word boundaries find them — including words in Chinese and Japanese, which are not separated by spaces — plus runs of spaces and single punctuation marks; an emoji, a flag or a letter with its accents is never split. It reaches the ceiling sooner than line mode. Past the ceiling the tool says it cannot compare the texts that way. It never guesses that "everything changed".
Tokens are counted by the site's token counter, in a Web Worker:
- Exact for the OpenAI models whose tokenizer runs in the browser (o200k_base), and labelled so.
- An estimate (characters ÷ 4) for every other model, and labelled estimate. Anthropic, Google and xAI count tokens through their own APIs, which this page does not call.
- A request is counted as a conversation: its text, plus the per-message framing and tool definitions only where the provider documents them. What cannot be counted — an image, say — leaves the total open, shown as at least. The difference between two open totals is the difference in what was counted, and says so.
Cost comes from Salyro's price list and the same function Salyro prices usage with (calculateCost): each version is one request of its input tokens plus the output you entered, priced without caching; a month is that times the requests a day times 30. A model with more than one price band is priced in the band each version's input falls in. A model without a price is not priced, never $0.
The cache. Anthropic's caching page states that a cache hit needs an identical beginning of the prompt — "Cache hits require 100% identical prompt segments" — and that the prefix is built in the order tools, then system, then messages, where a change at one level invalidates that level and every level after it. For Anthropic's models, then, the tool finds the first change:
- For text, the first character that differs, and the tokens before it — at most, because a provider caches up to a breakpoint, not to any character.
- For requests, the first block that differs — the tool definitions, the system prompt, or a message — and the tokens of everything before it.
On Anthropic, a change at the very start leaves nothing a cache entry written by the old version can serve, and what is left before the change is compared with the shortest prompt it caches on that model. For a provider whose rule has not been read, the summary says rule unknown: the tool shows where the first change is and what an identical-prefix cache would do, and claims nothing about that provider's cache.
What it does not know
- Other providers' cache rules. OpenAI's, Google's and xAI's caching pages could not be read when this was built. For their models the tool says their matching rule is unknown, and only notes what would happen if they cached on an identical prefix.
- Exact counts for Claude, Gemini and Grok. Their token counts here are estimates, so "shorter than the minimum the provider caches" is said as an estimate too.
- Invisible differences. When two versions differ only in line endings (CRLF and LF), in whitespace or in Unicode normalisation, the diff looks empty; the tool says which it is, because the tokens and the cache still see a different prompt.
- Settings that reset the cache. Only the tools, the system prompt and the messages are compared block by block. Anthropic's page lists settings that also invalidate its cache, such as the tool choice and the thinking configuration. When only settings changed, the tool points there rather than deciding.
- Your traffic. Whether a later request finds the new version cached depends on when requests arrive and on the cache lifetime. The cost figures are priced without caching; use the prompt caching calculator for what caching saves.
- The answer. It does not run either prompt, so it cannot say whether the change makes the output better or longer. Output tokens are the number you enter, the same for both versions.
FAQ
Why is the change in tokens marked "estimate"?
The model you picked has no tokenizer that runs offline in a browser, so both versions are estimated at four characters a token. The difference between two estimates is an estimate too. Pick an OpenAI model to count exactly with o200k_base.
Why does adding a date at the top matter so much?
Where a provider's cache matches from the start — as Anthropic documents for its own — a line that changes every day, put first, makes every request after the change a cache miss: nothing after it can be read from the cache. The same line at the end keeps the rest of the prompt cacheable.
Why "cannot compare"?
The texts differ in so many places that comparing them would need more than a million cells of memory. Switch to line mode, or compare a smaller part.
Sources
Prices come from Salyro's catalogue, with the revision and each provider's pricing page named under the result. The cache rule and the minimum cacheable prompt name the provider page they were read from, and the date: Anthropic's prompt caching page. Exact token counts use OpenAI's published encodings.
Where the numbers come from
- Model and pricing data is a snapshot of the catalogue Salyro itself uses, taken when this site was built.
- Facts about models and providers that are not in that catalogue carry their own source and the date they were checked, and are shown as unknown where no reliable source exists.
