Prompt Token Reducer

Shrink prompts with safe clean-ups: strip HTML, minify JSON, convert tables to CSV, drop filler and tracking URLs. See tokens and money saved and every change.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Prompt Token Reducer?

Most token waste in real prompts is not in the wording. It is in what gets pasted: HTML markup from a scraped page, pretty-printed JSON, padded Markdown tables, tracking parameters on links, the same line copied twice, and stock phrases like "in order to" and "please note that". The Prompt Token Reducer removes that waste with rules you switch on and off, and shows the token count before and after.

Every change is listed, so nothing is altered silently: how many HTML tags were removed, which filler phrases were replaced, which URLs lost which parameters. Pick a model to see what the saving is worth across a million calls. Code inside ``` fences is left alone.

  • Ten switchable transforms with a description of each
  • Exact before and after token counts (o200k_base)
  • Savings per million calls at any listed model's price
  • Change log listing every edit made
  • Fenced code blocks and prompt XML tags preserved
  • Numbers in JSON kept exactly
Read the guide: How to Reduce LLM Token Usage and API Cost

Updated

How to use the Prompt Token Reducer

  1. Paste a prompt, scraped page, JSON payload or notes, or keep the example.
  2. Switch transforms on or off. Defaults are the ones that do not change meaning.
  3. Compare the before and after token counts and the percentage saved.
  4. Choose a model to see the saving per million calls at its input price.
  5. Read the list of changes and the reduced text, then copy or download it.

Worked examples

The example prompt with default transforms

Input

An HTML refund policy, a pretty-printed JSON array, three blank lines, a URL with utm_source, utm_medium and utm_campaign, filler phrases and a duplicated last line

Output

221 tokens down to 134 (o200k_base), a 39% cut

HTML tags, JSON whitespace, tracking parameters and filler account for nearly all of it; the instructions and data are unchanged.

What a saving is worth

Input

87 tokens saved per call, GPT-6.1 Sol at $2 per 1M input tokens

Output

$174 per million calls

87 x 1,000,000 calls = 87M tokens; 87 x $2 = $174.

Background and insight

API pricing is per token, and input tokens are paid on every call. A system prompt that is 400 tokens longer than it needs to be costs 400 million extra tokens per million requests. At $2 per million input tokens, that is $800, before counting the latency of processing them. Shorter prompts also leave more of the context window for the material that matters.

The transforms are deliberately conservative. Whitespace collapse keeps indentation and tabs. HTML stripping only removes real HTML tag names, so prompt tags such as <context> and <example> survive. JSON minification removes whitespace outside strings without re-serialising, so a long ID like 12345678901234567890 keeps every digit. The JSON-to-CSV transform refuses arrays whose numbers would lose precision. Link rewriting keeps the URL. Filler replacements are fixed phrase swaps ("due to the fact that" to "because") that do not change meaning.

Two transforms trade information for tokens and are off by default. Stripping Markdown removes emphasis and heading levels the model might use. Converting JSON or Markdown tables to CSV drops repeated field names, which saves the most on long arrays of records but means the model has to read columns by position from the header row.

Common use cases

  • Cleaning scraped web pages

    Remove markup, scripts and tracking links before passing a page to a summariser.

  • Trimming system prompts

    Cut filler and duplicated rules from a prompt that is sent on every request.

  • Compacting data for context

    Minify JSON or convert record arrays to CSV for retrieval or analysis prompts.

  • Budgeting a feature

    Show what a prompt clean-up is worth per million calls before deciding to invest in it.

Tips and limitations

  • Prompt caching often saves more than trimming for long, stable prefixes. Keep the static part first and identical across calls.
  • CSV is compact for flat records but loses field names per row; keep JSON when objects are nested or sparse.
  • Do not strip Markdown from instructions where headings or bold carry priority.
  • Counts use OpenAI's o200k_base; percentages saved are similar on other tokenizers.
  • Always read the changes list before using the reduced text in production.
  • Processing happens in your browser; nothing is uploaded.

Frequently asked questions

Does whitespace count toward tokens?

Yes. Runs of spaces, indentation in pretty-printed JSON and blank lines all become tokens. Collapsing them is usually the easiest saving.

Is CSV cheaper than JSON for sending data to an LLM?

For arrays of flat records, usually yes, because field names appear once in the header instead of in every row. For nested or sparse objects, JSON is clearer and the saving is smaller.

Will removing filler phrases change what my prompt means?

The replacements are fixed phrase swaps such as "in order to" to "to" and "due to the fact that" to "because". Each one is listed so you can check it.

How is the saving per million calls worked out?

Tokens saved per call x 1,000,000 calls x the model's input price per million tokens. 100 tokens at $2.50 per million is $250.

Does the reducer touch code in my prompt?

Text inside ``` fenced blocks is left as is by the text clean-ups, so indentation and spacing in code survive.

Why are some transforms off by default?

Stripping Markdown and converting to CSV remove information the model may use, such as emphasis or field names, so you choose when that trade is worth it.

Is there an in-depth guide to the Prompt Token Reducer?

Yes. “How to Reduce LLM Token Usage and API Cost” covers the background, how it works, common pitfalls and worked examples. Read the full guide.