Start with something real.
Paste a natural-language prompt, or try the sample. Code and detected quoted literals are kept unchanged.
A little less prompt. A little more room.
Turn wordy instructions into a smaller prompt.
Compare the result. Keep what works.
No account needed · Free, open-source SDK
A little less, right here.
Your complete result will appear here.Your text is processed by the hosted service. Prompt contents are not saved to our database. Privacy details
Small steps. Clear results.
Paste a natural-language prompt, or try the sample. Code and detected quoted literals are kept unchanged.
Compare the complete output, including any decoder. Short inputs may already be as compact as they need to be.
Try both versions with your model. Adopt compression when the answer stays useful and the complete cost improves.
Fits into your code.
Use the JavaScript SDK locally, or the hosted API with a key. You decide which prompts to compress and how to evaluate them.
Read the quick startnpm install tokenshrinkimport { compress } from 'tokenshrink';
const result = compress(yourPrompt);
// Complete output, including any decoder.
const prompt = result.compressed;
// Estimates. Check with your model tokenizer.
console.log(result.stats.tokensSaved);Designed to earn your trust.
Token counts are estimates, not a promise of lower bills or identical answers. Caching, output and retries matter too. Our experimental engine stays separate from the product you use today.