PTPureToolkit

Guide

How to Reduce System Prompt Tokens Without Changing Code Blocks

Clean long system prompts with local token estimates while preserving fenced code, JSON blocks, XML tags, and YAML-like sections.

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.

Embedded local tool

System Prompt Token Optimizer

Options
Optimization mode
Token counts are approximate. This MVP uses a local heuristic and includes an extension hook for exact tokenizer support later.

Optimized prompt

Optimize a prompt to see approximate token savings, character savings, and copyable output.