TokenPad
Optimisation

Prompt Token Optimizer

Strip the tokens you are paying for and getting nothing back.

Original
Transformations
Tokens savedExact
0no change
Before
After
Saved / month$0.00
Saved / year$0.00

Every transformation here preserves meaning. Word spacing is deliberately left alone: in most BPE vocabularies a leading space belongs to the word token, so stripping it raises the count rather than lowering it.

Optimised output
{"task":"classify","categories":["billing","technical","account"],"instructions":"Read the ticket and pick one category."}

What this tool tells you

Some of the tokens in your prompt carry meaning. Others are indentation, trailing spaces, blank lines and repeated JSON punctuation — structure that exists for human readers and does nothing for the model. You pay identically for both. This tool separates them, shows the difference in tokens, and converts it into a monthly and annual figure at your request volume.

The honest headline: on English prose the saving is two or three percent and not worth your afternoon. On pretty-printed JSON, tabulated data or deeply indented code it is routinely thirty to fifty percent, and it recurs on every request forever. The tool shows your actual number rather than a marketing one.

What each transformation does

Minify JSON

Re-serialises valid JSON without indentation or line breaks. Almost always the largest single win, because pretty-printing adds two to four tokens per line and a nested object has a lot of lines. If the input is not valid JSON the transformation is skipped rather than applied destructively.

There is no evidence that indentation helps a model parse well-formed JSON — the structure is carried by the braces and commas, not the layout. Minify what you send, keep the readable version in your logs.

Collapse repeated spaces

Runs of two or more spaces become one. This catches aligned tables, padded columns and the artefacts of string concatenation. Single spaces between words are deliberately left alone — see below, because this is where people go wrong.

Trim line ends and collapse blank lines

Trailing whitespace is invisible in your editor and billed like anything else. Runs of three or more newlines collapse to two, which preserves paragraph separation while removing accidental gaps.

The optimisation that backfires

The instinct is to strip all whitespace. Do not. In most byte-pair vocabularies the leading space is part of the word token — the encoder learned " the" as a unit, not "the". Removing spaces between words forces it off those common merges and onto fragments, and the token count goes up.

The distinction that matters is structural whitespace versus semantic whitespace. Indentation, alignment padding and trailing spaces are structure, and removing them is free. Word spacing is semantic, and removing it costs you twice: more tokens and worse comprehension. Watch it happen in the tokenizer playground — paste a sentence, then paste it again with the spaces removed, and compare.

Beyond whitespace

The automatic transformations here are the safe, lossless ones. The larger savings usually require judgement:

  • Repeated JSON keys. An array of 500 objects repeats every key 500 times. Sending column headers once and rows as arrays can halve a payload.
  • Base64 in prompts. Encodes at roughly one token per two characters and is nearly always avoidable.
  • Restated instructions. The same rule expressed three ways out of caution costs three times as much and does not improve compliance. The system prompt analyzer finds these by showing what each paragraph costs per year.
  • Whole documents where a passage would do. The largest saving available to most teams, and it is a retrieval problem — see the text splitter.

Is it worth doing

Multiply the tokens saved by your monthly request count and look at the annual figure the tool shows. Below a few hundred dollars a year, spend your attention elsewhere. Above a few thousand, this is one of the highest-return hours available to you, because unlike most optimisations it is permanent and carries no accuracy risk. Model the full picture in the cost calculator.

Frequently asked questions

Does this change what the model understands?
The transformations offered here are lossless with respect to meaning: collapsing runs of spaces, removing trailing whitespace, dropping blank lines, and re-serialising valid JSON without indentation. The model reads the same information. What changes is how many tokens it takes to say it.
How much can I realistically save?
On plain English prose, very little — perhaps two or three percent, and that is the honest answer. On pretty-printed JSON, tabulated data or code with deep indentation, thirty to fifty percent is common. The tool shows the actual figure for your text rather than a marketing number.
Should I strip all whitespace to save tokens?
No, and this is a common and expensive mistake. In most BPE vocabularies a leading space is part of the word token, so removing spaces between words forces the encoder off its common merges and onto fragments, which increases the count. Structural whitespace — indentation, repeated blanks — is waste. Word spacing is not.
Is minified JSON worse for accuracy?
There is no evidence that indentation helps model comprehension of well-formed JSON; the structure is carried by the braces and commas, not the layout. Minify what you send to the model, and keep the pretty version in your logs where a human reads it.

More optimisation tools