LLM Token Counter: A Step-by-Step Guide
Reviewed by the FreeOnline.fyi team · Updated 2026-09-17
What a token count really tells you
A token count is the number that decides two practical things: whether your prompt fits inside a model's context window, and what that prompt costs as input. Words and characters are only a rough proxy, because every model family splits text into different chunks, so a character counter gets you into the neighbourhood and no further.
In our own testing with real prompts, plain English prose lands close to four characters per token, which is where the old "divide the character count by four" shortcut comes from. It breaks down fast on code, minified JSON, base64 blobs, UUIDs and non-Latin scripts — there we routinely see closer to two and a half to three characters per token, so the shortcut can be badly low. If your prompt is mostly structured data or source code, trust the counter rather than the rule of thumb.
Tokenizers are vendor-specific and openly documented. OpenAI's help page on what tokens are and how to count them and the open-source tiktoken library are the reference points worth reading if you want to understand why two models disagree on the same text.
Paste the complete prompt, not just the ask
Open the LLM Token Counter and paste everything you actually intend to send: the system message, few-shot examples, retrieved documents, tool or function schemas, and the conversation history your app re-sends on every turn. A live character, word and line counter sits in the corner of the textarea so you can see at a glance what you pasted.
The most common miss we see is the system prompt. A 900-token instruction block plus five worked examples is often several times larger than the user's question, and it is billed on every single call. Counting only the user turn gives you a number that looks cheap and predicts nothing useful.
Counting runs locally in your browser, so the text is not uploaded anywhere. That makes it reasonable to paste proprietary snippets or long transcripts, though it is still good hygiene to strip real API keys and customer identifiers before pasting anything into any web page. The textarea accepts up to 200,000 characters, which covers most coding-agent contexts.
Pick the model before you trust the number
Token counts are model-specific. The gpt-4o, gpt-4.1 and o-series models share a tokenizer family, while Claude and Gemini each segment text their own way, so the same paste can shift by a noticeable margin when you switch the select. Pick the model you are genuinely going to call, then glance at the per-1M input price shown next to it.
Switching models in the dropdown is also the quickest way to answer a budgeting question. If a prompt is comfortably affordable on a mini model and uncomfortably expensive on a frontier model, you have found your routing decision in about ten seconds, without writing a benchmark.
One caveat: the select covers the popular models rather than every model ever released. For a fine-tune, a self-hosted model or a brand-new release, use the closest tokenizer family as an approximation and treat the result as a sanity check rather than a bill.
Reading the context-window bar
Below the token count you get a slim gauge showing something like 1,240 / 128,000 — about 1%. That single ratio is what stops long-running agents from failing halfway through a task, because it tells you how much room is left before the model starts truncating or the provider rejects the request.
Remember that the bar measures input only. You still need space for the completion, plus any reasoning tokens if you are using a reasoning model, so a prompt at 95% of the window is effectively unusable even though the number technically fits. As a working rule, we like to keep agent contexts under roughly three quarters of the maximum before the model has answered, which leaves headroom for tool output coming back.
Very long context also tends to cost more and respond more slowly, and quality can drift when a prompt is padded with material the model does not need. If a context is ballooning, trimming retrieved documents is usually cheaper than moving to a larger-window model.
Turning tokens into dollars per call
The cost line converts your count into USD at the selected model's input price, and echoes it in practical terms. A 4,000-token prompt on a model priced at $2.50 per million input tokens works out to roughly $0.01 per call, or about $10 per 1,000 calls — a figure you can compare directly against the value of the task.
The estimate is input-only, which matters more than it sounds. Output tokens are billed separately and usually at a higher rate, cached input is often discounted, batch endpoints are cheaper again, and reasoning models may bill invisible thinking tokens. Providers publish current pricing and change it regularly, so verify anything that feeds a real budget rather than quoting our number in a spreadsheet.
Agent loops are where the arithmetic surprises people. Twenty model calls per task, each re-sending a growing history, is not twenty times one prompt — it can be several times that. Counting the worst-case context once, then multiplying by your expected call count, gives a far more honest ceiling. The counter is one of several browser-only utilities on FreeOnline.fyi that need no account and no key.
Mistakes that skew your estimate
Pretty-printed JSON is the classic trap. Indentation, newlines and repeated keys all consume tokens, so a formatted sample can count noticeably higher than the minified payload you actually transmit. If your client sends compact JSON, minify before you count; if it sends it pretty, count it as-is.
Another frequent gap is forgetting the scaffolding: tool definitions, JSON schemas, retrieved chunks and the safety preamble. In chat apps, history re-sent each turn is the sneakiest of all, because the cost per turn grows as the conversation lengthens rather than staying flat.
Finally, treat the output as an estimate, not an invoice. Different tokenizers, Unicode edge cases and provider-side wrappers all introduce small differences, and the exact numbers come from a provider's own token-counting endpoint or a local library like tiktoken. Use the counter for fast sanity checks before you spend money or blow a context window, and confirm important figures against your provider's documentation before you commit to a budget.