LLM Token Counter
Count tokens and estimate API cost for GPT, Claude, Gemini, and more. ChatML overhead, Markdown options, and multi-model compare — all local in your browser.
All processing on this page runs locally in your browser unless noted otherwise.
Token counting runs locally in your browser. Your text never leaves your device.
How to use
- Choose Text, Chat, or Compare mode.
- Optionally clean Markdown (Mermaid, HTML, links, etc.) before counting.
- In Chat mode, add System / User / Assistant turns (color-coded), or Import Chat JSON — framing overhead is included. Export JSON for scripts.
- Use output scenario presets and an optional cost alert threshold.
- Use Compare to pick 2–3 models and contrast tokens & estimated cost.
- Need chunks under a token budget? Split by tokens · multi-file? Batch files
FAQ
Why some models are estimated instead of exact count?
Anthropic, Google, and most open-weight vendors do not ship a browser-safe tokenizer for current models. Their official count_tokens APIs would upload your prompt — we never call them. OpenAI and Qwen/GLM use local Exact tokenizers. Claude, Gemini, Llama, Mistral, and DeepSeek are local approximations for planning only.
Which models are counted exactly?
OpenAI GPT / o-series use js-tiktoken locally. Qwen2.5 and GLM-4 use Hugging Face Transformers.js tokenizers in the browser (Exact after the tokenizer downloads once). Claude, Gemini, Llama, Mistral, and DeepSeek stay Estimated.
What is Chat mode?
Chat mode counts System / User / Assistant messages with OpenAI-style ChatML framing overhead. Import messages JSON and export per-message token JSON for scripts.
Is my prompt uploaded?
No. Token counting runs entirely in your browser. Saving draft text is off by default; if you enable it, drafts stay in localStorage on your device only.
How do Markdown cleanup options work?
Independently toggle: remove Mermaid, remove code fences, strip HTML, strip links/URLs, collapse whitespace, and strip Markdown markers.