{"version":"v1","id":"prompt-compressor","matrix":"workflows","status":"live","updated":"2026-11-26","title":{"en":"Prompt & Context Compressor","zh":"提示词与上下文压缩器"},"h1":{"en":"Prompt Compressor & Token Reducer (Free, Runs Locally)","zh":"提示词压缩器：在线压缩 Token、降低 LLM 成本"},"description":{"en":"Cut prompt tokens with deterministic rules, then price the difference: original vs compressed tokens, saved per call, and monthly API savings at your run volume.","zh":"用确定性规则砍掉提示词里的冗余 token，再按真实运行量算清差价：原始与压缩后 token、单次省额、每月 API 节省。"},"answer":{"en":"Sogoh compresses prompts with deterministic rules, not another model call. The default 329-token system prompt drops to 279 tokens (−15.2%) in balanced mode; at 5,000 runs a day on a $2/M input model that is $15.00 a month. Code blocks, quoted strings, URLs and numbers are protected.","zh":"Sogoh 用确定性规则压缩提示词，不额外调用模型。默认 330 token 的 System Prompt 在标准档压到 288 token（−12.7%）；按每天 5,000 次、输入 $2/百万 token 计算，每月省 $12.60。代码块、引号字符串、URL 与数字全程受保护。"},"keywords":{"en":["prompt compressor","prompt compression tool","token reducer","reduce prompt tokens","compress prompt online","llm prompt compressor","claude prompt compressor","context compression","token optimization","prompt minifier","system prompt compressor","rag context compression","json prompt minifier","prompt token calculator","reduce llm api cost","prompt compression techniques","token reduction tool","free prompt compressor","prompt cost savings calculator","llm token savings calculator"],"zh":["提示词压缩器","提示词压缩","token 压缩","上下文压缩","提示词精简","提示词瘦身","token 优化","压缩提示词","提示词压缩工具","在线提示词压缩","降低 API 成本","LLM 成本优化","系统提示词压缩","RAG 上下文压缩","prompt 压缩","token 节省计算","提示词 minifier","免费提示词压缩器"]},"formula":[{"title":{"en":"Paste the prompt you actually send","zh":"粘贴你真正发出去的提示词"},"body":{"en":"Long system prompts, JSON schemas and retrieved context are where the tokens hide. Code fences, inline code, quoted strings, URLs, emails, template variables and numbers are masked before any rule runs, so no mode can rewrite them.","zh":"长 System Prompt、JSON Schema 与检索上下文才是 token 藏身处。代码块、行内代码、引号字符串、URL、邮箱、模板变量与数字会先被占位保护，任何档位都改不到。"}},{"title":{"en":"Pick the least destructive mode that works","zh":"选够用的最轻档位"},"body":{"en":"Safe only normalises whitespace, Markdown emphasis and link syntax. Balanced also removes pleasantries and filler, minifies JSON/XML only when the whole pasted text is one document, and dedupes repeated long lines. Aggressive drops articles, pronouns, auxiliaries and sentence punctuation, so it has to be read before shipping.","zh":"轻度档只整理空白、Markdown 强调与链接语法；标准档再移除客套与填充词、在整段文本就是一份 JSON/XML 时压缩其空白、合并重复长行；极限档会删冠词、代词、系动词与句末标点，所以必须人工读一遍。"}},{"title":{"en":"Count tokens with the real vocabulary","zh":"用真实词表计数，不靠估算"},"body":{"en":"Tokens are counted with gpt-tokenizer (o200k_base), the same BPE vocabulary as OpenAI’s o200k models. Other providers tokenize differently, so their numbers are an estimate within a few percent — far closer than the “4 characters per token” rule, which fails badly on JSON and Chinese.","zh":"token 用 gpt-tokenizer（o200k_base）计数，与 OpenAI o200k 系列同一套 BPE 词表。其他厂商分词不同，误差在几个百分点内，但仍远好于「4 个字符 ≈ 1 token」——那条经验在 JSON 和中文上完全失效。"}},{"title":{"en":"Turn saved tokens into a monthly bill","zh":"把省下的 token 换成每月账单"},"body":{"en":"Cost per call = saved tokens ÷ 1,000,000 × input price. Monthly savings = cost per call × runs per day × 30. Only the input side is counted: compression shortens the prompt, not the answer, so output tokens and cache discounts stay out of the number.","zh":"单次省额 = 省下 token ÷ 1,000,000 × 输入单价；每月省额 = 单次省额 × 每天次数 × 30。只算输入侧：压缩缩短的是提示词而不是回答，所以输出 token 与缓存折扣都不计入。"}}],"faq":[{"q":{"en":"Does compressing a prompt make the model dumber?","zh":"压缩提示词会让模型变笨吗？"},"a":{"en":"Safe mode cannot remove a word, so answer quality is unchanged. Balanced only removes politeness, filler and duplicated lines, which carry no instruction. Aggressive removes articles, pronouns and auxiliaries; meaning usually survives, but a sentence like “send it to the client, not the vendor” is exactly where a deleted word matters. Read the diff before using aggressive on customer-facing prompts.","zh":"轻度档不删任何词，回答质量不变。标准档只删客套、填充词与重复行，这些本身不承载指令。极限档会删冠词、代词与系动词，意思通常还在，但像「发给客户，不要发给供应商」这种句子，删一个词就出事。面向客户的提示词请先看差异再决定。"}},{"q":{"en":"Is my prompt uploaded anywhere?","zh":"我的提示词会被上传吗？"},"a":{"en":"No. Compression and token counting run in the page with bundled JavaScript; there is no request that carries your text. The page is static, has no login and no server-side compression endpoint, so the only copy of the prompt is the one in your browser tab. Clearing the field removes it.","zh":"不会。压缩与计数都在页面内用打包好的 JavaScript 完成，没有任何请求携带你的文本。页面是静态的，不需要登录，也没有服务端压缩接口，提示词只存在于当前浏览器标签页。清空输入即删除。"}},{"q":{"en":"Which tokenizer does the counter use, and how exact is it?","zh":"计数器用哪个分词器，有多准？"},"a":{"en":"It uses gpt-tokenizer with the o200k_base vocabulary, loaded lazily in the browser. Counts are exact for OpenAI’s o200k models. Claude, Gemini and DeepSeek use different vocabularies, so their real counts differ by a few percent; the saved percentage and the direction of the bill are still reliable.","zh":"使用 gpt-tokenizer 的 o200k_base 词表，在浏览器里按需加载。对 OpenAI o200k 系列是精确值；Claude、Gemini 与 DeepSeek 词表不同，真实计数会差几个百分点，但节省比例与账单方向仍然可靠。"}},{"q":{"en":"Why not just divide characters by four?","zh":"为什么不直接用字符数除以 4？"},"a":{"en":"Because the ratio is not stable. English prose sits near four characters per token, but JSON keys, base64, code, URLs and Chinese are much denser: a Chinese character is often one token or more, not a quarter. The 4:1 shortcut undercounts exactly the inputs that make prompts expensive, so this page loads the real vocabulary instead.","zh":"因为比例并不稳定。英文散文大约是 4 个字符 1 个 token，但 JSON 键、base64、代码、URL 与中文密度高得多：一个汉字经常就是 1 个 token 甚至更多，不是四分之一个。4:1 的捷径恰好会低估最贵的那些输入，所以这里直接加载真实词表。"}},{"q":{"en":"Why is only the input side counted?","zh":"为什么只算输入侧？"},"a":{"en":"Compression changes the prompt, not the completion. Counting hypothetical output savings would inflate the result, and prompt-caching discounts vary by provider and prefix stability, so they are excluded too. The number you see is the conservative, input-only saving at list price.","zh":"压缩改变的是提示词，不是回答。把假设的输出节省算进来会虚高；缓存折扣又取决于厂商与前缀稳定性，也一并排除。页面给出的是按挂牌价、只算输入侧的保守值。"}},{"q":{"en":"Can I compress RAG context, Chinese prompts or mixed-language text?","zh":"能压缩 RAG 上下文、中文或中英混合提示词吗？"},"a":{"en":"Yes. RAG chunks compress like any prompt, and Chinese plus mixed-language text is handled: pleasantries are removed only at sentence starts, and token counting uses the same BPE vocabulary (a Chinese character often costs one token or more, so the savings are real). For RAG, compress the instruction template rather than the retrieved evidence — deleting a citation can change the answer even when the prompt gets shorter.","zh":"可以。RAG 片段和普通提示词一样能压，中文与中英混合文本也支持：客套语只在句首或标点后移除，token 计数使用同一套 BPE 词表（一个汉字经常就是 1 个 token 甚至更多，所以省下来的是真金白银）。做 RAG 时请压指令模板，不要压检索到的证据——删掉引用会让答案变样，哪怕提示词更短。"}}],"sources":[{"label":"gpt-tokenizer — BPE tokenizer for o200k_base and cl100k_base (MIT)","url":"https://github.com/niieani/gpt-tokenizer"},{"label":"OpenAI — tokenizer tool and token guidance","url":"https://platform.openai.com/tokenizer"},{"label":"OpenRouter — Models API (price snapshot source)","url":"https://openrouter.ai/api/v1/models"},{"label":"LLMLingua — prompt compression research (arXiv 2310.05736)","url":"https://arxiv.org/abs/2310.05736"},{"label":"Anthropic — effective context engineering for AI agents","url":"https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents"},{"label":"OpenAI — API pricing","url":"https://platform.openai.com/docs/pricing"},{"label":"Anthropic — API pricing","url":"https://www.anthropic.com/pricing"},{"label":"Google — Gemini API pricing","url":"https://ai.google.dev/gemini-api/docs/pricing"}],"localized":{"en":{"url":"https://www.sogoh.com/tools/prompt-compressor/"},"zh":{"url":"https://www.sogoh.com/zh/tools/prompt-compressor/"}},"license":"Free to reuse with attribution and a link to the source page."}