LLM Token Counter
Runs locallyExact OpenAI o200k/cl100k token counts plus labelled estimates for Claude, Gemini and Llama.
What is LLM Token Counter?
Count exact tokens for OpenAI models (`o200k_base` and `cl100k_base` via js-tiktoken) and clearly labelled heuristic estimates for Claude, Gemini, Llama, and Mistral. Visualize color-coded token boundaries, inspect token IDs, measure context-window utilization against versioned model specs, and estimate prompt cost locally.
How to use LLM Token Counter
- Step 1
Select a target model (e.g. GPT-4o, o3-mini, Claude Sonnet 4, Gemini 2.5 Pro, Llama 3.3).
- Step 2
Paste your prompt, system message, or drop a text/Markdown/JSON file.
- Step 3
Inspect exact token boundaries (for OpenAI encodings) or clearly labelled estimates, plus token IDs and context meter.
- Step 4
Optionally add chat message overhead or send the token count directly to the LLM Cost Calculator.
Features
- Exact BPE tokenization for OpenAI `o200k_base` and `cl100k_base` via js-tiktoken
- Clearly labelled estimates for Anthropic Claude, Google Gemini, Meta Llama, and Mistral
- Color-coded token boundary visualizer and raw token ID list
- Context window progress bar driven by versioned `src/data/llm-models.json`
- Characters/words/tokens ratios, chat message overhead helper, and batch prompt mode
Example
Input
Summarize the JSON schema validation errors cleanly.
Output
9 tokens (o200k_base exact) · 51 chars · 7 words
Shows exact BPE token segmentation and context window percentage.
Frequently asked questions
How are tokens counted?
Text is split into tokens by the model’s tokenizer. A token is often a word piece, so counts are not the same as words.
Are the counts exact for every model?
OpenAI counts use the matching tokenizer. For Claude, Gemini, Llama and others the tool shows a labelled estimate, because exact counts require the provider’s tokenizer.
Why do models give different counts for the same text?
Each model family uses its own tokenizer and vocabulary.
How can I reduce tokens?
Remove repeated instructions, shorten examples, avoid pasting large unused context, and use structured, compact formats.
Does this send my prompt anywhere?
No. Counting happens in your browser.
Related tools
LLM API Cost Calculator
Compare monthly LLM API costs with prompt caching, batch discounts and editable model prices.
JSON Formatter & Validator
Format, validate, minify, repair, sort keys and query JSON with Tree and Table views.
Markdown Editor
Split live GFM Markdown editor with DOMPurify sanitization, TOC, word stats and HTML/PDF export.