Prompt cleanup should be conservative
System prompts often contain policy text, tool instructions, formatting rules, examples, and machine-readable blocks. Blind compression can break the very instructions that make a prompt reliable. A local optimizer should preserve fenced code, JSON, XML, and YAML-like sections before applying text cleanup.
Approximate token counts are still useful for product work. They help you compare before and after versions, identify repeated boilerplate, and estimate whether a prompt is likely to fit within a target context budget.
Choose the right optimization mode
Light mode is safe for routine cleanup: trim, normalize line endings, remove trailing spaces, and collapse excessive blank lines. Medium mode is useful when prompts have duplicated lines, repeated markdown separators, or verbose phrases that can be shortened without changing meaning.
Aggressive mode is for review workflows, not blind deployment. It may compact headings, remove filler, and minify valid JSON blocks. Always diff the result and run your prompt tests after aggressive changes.
Keep sensitive prompts local
System prompts can contain product strategy, internal tool names, or private operational details. The optimizer below runs in the browser and does not call tokenizer APIs, LLM APIs, or backend services. It reports approximate token savings without collecting the prompt content.