Analyze what eats your AI agent's context window. Drop in your CLAUDE.md, skill files and .mcp.json — get real token counts, a per-file breakdown, actionable trim suggestions, and a before/after savings simulator.
🔴 Live demo: https://devilking7x.github.io/contextdiet/
- Real token counting — uses
gpt-tokenizer(browser-compatible BPE) right in your browser. No estimates, nochars ÷ 4hacks. - Drag & drop — drop
CLAUDE.md,SKILL.md,.mcp.json(or any text/markdown/JSON) and get instant analysis. - Per-file breakdown — ranked table + bar chart, largest offenders first, with kind badges, share-of-total, and inline previews.
- Context window gauge — visualizes your % of the window with the "keep under 20%" rule marked. Configurable window size (50k / 100k / 200k / 1M / custom).
- Trim suggestions — actionable, impact-ordered advice ("this file is 21k tokens — consider splitting into skills"), including cross-file boilerplate deduplication and JSON minification.
- Before/after simulator — exclude files and toggle suggestions to see projected token savings before you change a single line.
- One-click sample bundle — a chunky
CLAUDE.md, two skills and an.mcp.jsonso the demo works instantly. - 100% local-first — no backend, no uploads, no tracking. Your files never leave the browser. State persists in
localStorage.
- Open the live demo.
- Either drag & drop your files, or click "Try the sample bundle".
- Check the gauge — are you under the 20% rule for your model's window?
- Read the trim suggestions, tick the ones you'll act on.
- Use Before / after to preview the savings, then go put your context on a diet.
pnpm install
pnpm dev # dev server
pnpm build # typecheck + production build (dist/)Sample files can be regenerated with pnpm gen-samples.
- TypeScript + React 19 + Vite 7
- Tailwind CSS v4 (dark premium UI)
- gpt-tokenizer — real BPE token counting, bundled for the browser
- lucide-react — icons
- GitHub Pages deploy via Actions (
base: '/contextdiet/')
Text is encoded with gpt-tokenizer's BPE encoder (the same token family as modern OpenAI models) in 200k-character chunks and summed. Counts are accurate estimates — exact model internals may differ slightly, but they're in the right neighborhood for diet planning.
MIT — see LICENSE.

