LLM Token Counter
Count the tokens in any text or prompt for GPT-5, GPT-4, Llama, Claude, and Gemini. Exact text tokenization for supported OpenAI and Llama 3 models, runs entirely in your browser, nothing is uploaded.
Loading the exact o200k_base tokenizer in your browser…
How to use this tool
Paste or type your text
Type a prompt, paste an API request body, or drop in any text you plan to send to a language model. The counter updates the count immediately as you type, no submit button required.
Choose the target model
Select the target model. Supported OpenAI and Llama 3 encodings count plain text tokens. Llama 4, Claude, and Gemini show labeled estimates. Verify production counts with the model tokenizer or provider API.
Read the token count
The tool returns the token count alongside word, character, sentence, and line counts so you can compare all the metrics at once. Use the token number to check against the model's context window or price per million tokens.
Trim the prompt if needed
If the count exceeds your budget or context window, edit the text in place and the count drops live. Common wins include dropping redundant instructions, merging examples, or summarising prior messages that no longer need full context.
About this tool
The LLM Token Counter tells you how many tokens a piece of text will use before you send it to a model. Tokens are the units language models actually bill and budget by, so knowing the count up front helps you stay inside context windows, control API costs, and trim prompts that are larger than they need to be. Paste any prompt, choose a model, and you get the token count alongside word, character, sentence, and line statistics.
Supported OpenAI encodings and the Llama 3 tokenizer count text locally. Llama 4 uses a different tokenizer and is shown as an estimate here, alongside Claude and Gemini. Text counts exclude chat templates, system formatting, and multimodal inputs. Check provider usage for billing.
Why token count matters
Every model has a context window measured in tokens, and most APIs bill per input and output token. Counting tokens before a request lets you confirm a prompt fits, predict cost, and decide whether to summarise or chunk long inputs. It is especially important for retrieval-augmented generation and agentic loops, where appended context can quietly push a request over the limit.
Tokens vs words vs characters
Tokens can be words, word fragments, punctuation, or byte sequences. The selected tokenizer determines the count. This tool loads supported OpenAI and Llama 3 encodings for text counts, while Llama 4, Claude, and Gemini are estimated.
Exact vs estimated counts
The exact label means the selected text tokenizer loaded successfully, not that the number equals a full API bill. Chat templates and other inputs add tokens. Llama 4, Claude, Gemini, and tokenizer-load fallbacks show estimates. Use provider usage or the model tokenizer for production verification.
Popular token guides
Practical explainers on tokenization, context windows, and cost optimization for LLM applications.
Frequently asked questions
What is a token in an LLM?
How accurate is this token counter?
Why do different models report different token counts?
Is my text sent to a server?
Related tools
LLM API Pricing Calculator
Compare API costs across major models (OpenAI, Anthropic, Google) with prompt caching.
Use tool ➜LLM VRAM Calculator
Calculate the VRAM needed to run or fine-tune any LLM at any quantization.
Use tool ➜Text Encoding Converter
Convert between Text, Base64, Binary, Hexadecimal, and Decimal formats.
Use tool ➜JSON Formatter
Validate, format, and minify JSON data with readable output and error detection.
Use tool ➜Use this tool on your own site
Drop the Token Counter into your blog, docs, or CMS with one iframe snippet. Free, no signup. See all embeddable tools
