The LLM Token Counter on tokenworkbox.com is the main tool: paste a prompt or Markdown, pick a model, and get token counts plus a rough API cost — all in the browser.
Quick start
- Open the token counter.
- Paste text (or load a local
.md/.txtfile). - Choose a model from the list — each option is tagged Exact or Estimated.
- Read tokens, context progress, and the cost sketch.
Nothing is uploaded. Counting stays on your device.
Text vs Chat vs Compare
Use the mode that matches how you call the API:
- Text — single blob (system prompt, README, code, long doc). Good default for docs and one-shot prompts.
- Chat — System / User / Assistant turns with OpenAI-style ChatML framing overhead. Role rows are color-coded. Import ChatML / messages JSON; export a session JSON with per-turn tokens and metadata.
- Compare — side-by-side tokens and cost for up to 3 models so you can see tradeoffs before you lock a stack.
Exact vs Estimated
Accuracy is labeled on purpose:
- Exact — OpenAI-family models via js-tiktoken (e.g. GPT-4o, GPT-4.1, o3 encodings), plus Qwen / GLM via browser Transformers.js tokenizers (downloaded once locally; text still never goes to our server).
- Estimated — Claude, Gemini, Llama, Mistral, DeepSeek, and similar. When an Estimated model is selected, the results area shows a clear disclaimer: counts are not official billing values; prose/code often lands around ±5–10%, with larger drift for emoji / non-Latin. For production billing, use the provider’s official token counting API.
We do not call vendor count APIs, so your prompt text stays local. See the FAQ: Why some models show “Estimated”?.
Markdown options that matter
Long docs often inflate counts with noise. Useful toggles:
- Skip Mermaid / remove code blocks when diagrams or fences should not count toward the prompt budget.
- Strip Markdown markers, HTML tags, or links/URLs when you care about rendered text more than source markup.
- Clean redundant whitespace when needed.
- Optional encoding override (
auto,o200k_base,cl100k_base,r50k_base, and HF ids where applicable) when you know which encoding your stack uses.
Model choice and Markdown switches persist in localStorage. Use Clear local settings to reset preferences (separate from clearing a draft). Large prompt drafts are not auto-saved by default for privacy.
The Tokenizer Inspector colorizes tokens for exact encodings. For very long Exact inputs (roughly >50k tokens), enable inspection deliberately — rendering every token can slow the page.
Cost and context
Cost uses published list prices (USD per 1M tokens). You can:
- estimate output with the ratio slider, or jump via scenario presets (e.g. Q&A ~20%, summary ~30%, code ~50–60%);
- set an optional cost alert threshold — estimates above your budget highlight in red;
- override USD / 1M for custom or enterprise rates.
The context progress bar turns yellow from ~70% and red from ~90% (or over limit), with a truncation-risk note when you are near the window.
Treat cost as a sketch for comparison — actual invoices may differ (discounts, caching, tool calls, retries).
Export
- Copy a summary, or export Markdown / CSV.
- In Chat mode, export JSON for scripts (per-message tokens, overhead, cost-related fields).
Related tools
- Too long for one call? Use Split by tokens (overlap + Markdown-aware chunks).
- Many files at once? Use Batch files.