About this tool
Before you paste a prompt into an API call — or wonder why a request was rejected for exceeding the context window — it helps to know exactly how many tokens you are about to send. This counter gives you precise counts, not guesses, for OpenAI models: it uses the gpt-tokenizer library with the real o200k_base encoding behind GPT-4o and the GPT-5.x family, and the cl100k_base encoding used by the GPT-4 and GPT-3.5 generation. The tokenizer data loads lazily on first use, so the page itself stays fast. For Claude and Gemini, whose tokenizers are not public, the tool shows clearly labeled estimates from character heuristics — roughly one token per four English characters and about 0.6 tokens per Chinese character — so you still get a usable order of magnitude. Every row also shows what percentage of that model’s context window your text would occupy, from 128K for GPT-4o class to 200K for Claude and a million for GPT-5.x and Gemini class, which is what actually matters when you are stuffing documents into a prompt. Once you know the token count, the built-in link takes you to the LLM API Cost Calculator to turn tokens into dollars. Everything is computed locally; your text never leaves the browser.
How to use LLM Token Counter
- Paste your prompt, document or chat transcript into the text area.
- Wait a moment on first use while the tokenizer data loads, then read the exact o200k_base and cl100k_base counts.
- Check the context-window percentage for each model to see whether the text fits, with headroom for the reply.
- Follow the link to the LLM API Cost Calculator to price the request, or trim the text and watch the counts update live.
Frequently asked questions
Why do different models report different token counts?
Each tokenizer slices text differently. The o200k_base encoding (GPT-4o, GPT-5.x) merges more patterns than cl100k_base (GPT-4, GPT-3.5), so the same text usually yields slightly fewer tokens under o200k_base. Always count with the encoding of the model you will actually call.
How accurate are the Claude and Gemini numbers?
They are heuristic estimates — Anthropic and Google do not publish their tokenizers. The tool assumes about one token per four English characters and 0.6 tokens per Chinese character, and labels these rows as estimates. Treat them as an order of magnitude, not an exact billing figure.
Does the count include chat message overhead?
No. Chat APIs add a few tokens per message for roles and formatting on top of the raw text. The counts here cover your text only, so leave a small margin when you are close to a model’s context limit.
Is my prompt uploaded anywhere?
No. The tokenizer runs entirely in your browser via a bundled JavaScript library. Your text is never transmitted, logged or stored.