JSON prompt token minifier
When you pass JSON into a prompt, every space, newline and indent is a billable token — on every call. This tool re-serializes your JSON at the minification level you choose and shows exactly how many tokens you save, so you can shrink large payloads without changing a single value.
How it works
The minifier parses your JSON (rejecting invalid input) and rebuilds it:
- Whitespace-only — removes all indentation and line breaks. Lossless and reversible; safe in every case.
- Key abbreviation — replaces long, repeated keys with short aliases and emits a one-line legend you paste once. Big wins on arrays of records.
- Full compact — whitespace stripping plus key abbreviation for the smallest possible payload.
Token counts use the standard ≈ 4-characters-per-token heuristic that closely tracks GPT and Claude tokenizers, so the before/after delta is a reliable guide to real savings.
Tips for prompt JSON
- Always strip whitespace. Pretty-printing is for humans; the model does not need indentation to parse JSON.
- Abbreviate only bulk data. For a 500-row table, short keys repeated 500 times save far more than the one-time legend costs.
- Keep a legend in the system prompt. One line like
t=title, p=pricepreserves meaning while keys stay tiny. - Re-check after edits. Adding fields can quietly re-inflate the payload — re-run before you ship a new version of the prompt.