Skip to content
100% local

LLM context compressor

Shrink pasted text or code so it costs fewer tokens before you send it to an LLM.

Input
Output

LLM context compressor

Paste code or prose that you are about to send to an LLM and this tool trims the parts that cost tokens without carrying much meaning, so more of your context budget goes to content the model actually needs. It is built for the everyday chore of pasting a file, a log, or a long instruction block into a chat window and watching the token count climb.

Four toggles control what gets removed. "Strip code comments" deletes // , # and -- line comments plus /* */ block comments — handy when you are pasting source files where the comments are for humans, not the model. "Collapse blank lines and trailing spaces" reduces runs of empty lines to one and trims stray whitespace at the end of every line. "Strip redundant indentation" removes the leading whitespace that every line shares, so a deeply nested code block pasted from an editor does not waste tokens on indentation the model does not need to reproduce structure. "Remove filler/stop words in prose" is the most aggressive option: it deletes a lightweight list of hedges and function words — very, basically, just, kind of, in order to, and similar — from ordinary sentences, which is why it is off by default and best reserved for prose rather than code.

The live tally under the output shows characters and an estimated token count before and after, plus the percentage saved, so you can see the effect of each toggle as you flip it. The token estimate is a rough character-based approximation (about four characters per token), not an exact count from any specific model's tokenizer — useful for judging relative savings, not for hitting an exact budget.

Everything runs as plain text and regex processing in your browser: there is no code parser, no AST, and nothing you paste is ever uploaded anywhere. That makes it safe to run on private source code, internal documentation or draft prompts before they leave your machine.

FAQ

Will this change what my code does?
The default toggles (strip comments, collapse blank lines, strip indentation) only remove whitespace and comments, so code behavior is unaffected. "Remove filler/stop words" rewrites prose and is not meant for code — leave it off when pasting source files.
How accurate is the token count?
It is an estimate based on roughly four characters per token, a common rule of thumb for English text. Different models tokenize differently, so treat the number as a guide to relative savings, not an exact count.
Why is comment stripping sometimes wrong on unusual code?
The tool uses plain regex, not a language parser, so a `//` or `#` inside a string literal can occasionally be mistaken for a comment marker. Review the output before pasting production code elsewhere.
Can I use it on markdown or plain prose, not just code?
Yes. Turn off "Strip code comments" if your text uses # for markdown headings rather than comments, and turn on "Remove filler/stop words" to trim hedging language from prose.
Is my text uploaded anywhere?
No. Compression runs entirely in your browser using plain string processing — your text never leaves your device.