Inspect a safe text fixture before planning a model request. Choose the supported encoding or an explicitly labelled approximation, and keep the counting method with the result.
Count your text
Count tokens locally
Your text and estimates stay in this browser. No API requests are sent to model providers.
Loading verified model records…
Tokens, characters and words measure different things
OpenAI’s tiktoken library uses byte pair encoding and provides named encodings, including the encodings supported by this tool. Official documentation.
A word count helps a person judge the length of a passage. A character count describes its written representation. A token count describes the units produced by a particular encoding. The counts are related, but they are not interchangeable. Punctuation, whitespace, repeated identifiers, structured markup and unfamiliar strings can all make a text fixture behave differently from a paragraph of ordinary prose.
Compare the same fixture when investigating an encoding difference. Keep line endings and whitespace unchanged, then switch only the selected method. If you edit the text and change the tokenizer at the same time, the result cannot isolate either effect. Preserve the fixture in your application test material so future prompt revisions can be compared consistently.
Exact encoding versus approximation
For supported OpenAI encodings, this tool uses a self-hosted tokenizer and the selected encoding data. That establishes the count for the supplied text under that encoding. It does not establish that every new model uses the chosen encoding, nor does it include application content you did not paste. Select an encoding deliberately rather than treating an OpenAI-labelled option as a universal token meter.
For providers without an implemented exact tokenizer here, the result is a labelled estimate based on the tool’s character heuristic. Use it for early sizing and comparison within the same method. Do not promote it to a provider-confirmed billable count. A precise-looking integer can still come from an approximation; the method label is more informative than the absence of a decimal point.
Claude provides a provider-side token-counting interface with a documented request shape and limitations. Official documentation.
Gemini documents its own token-counting methods and the treatment of different input types. Official documentation.
Use the relevant official counting interface when a decision needs provider-specific measurement. Keep the request shape aligned with the eventual inference call and inspect unsupported fields. The browser tool is convenient for a text fixture; it does not silently submit that text to those provider endpoints.
Count the request you will actually send
The user’s visible question is often only part of the application input. Your system instructions, retrieved passages, conversation history, examples and tool definitions may also contribute to the request. Keep a clear boundary around the fixture being measured. A useful record says whether the count covers a single passage or the assembled application input.
Media needs separate handling. A text count cannot measure an image, an audio clip or a video simply because the application stores a filename beside it. Inspect the model’s official input accounting and pricing for the relevant media type. If a tool cost estimate covers text only, retain that scope when sharing the result.
An output estimate is a planning assumption until the model produces a response. Keep observed response usage separate from an output cap: a configured maximum is a control on generation, not proof that every response consumed that amount. For a realistic workload, collect accepted outputs from representative tasks and inspect variation.
Turn a count into a cost scenario
Select a model where the tool offers a supported input-cost view, then inspect its rate and verification date. Continue to the AI API cost calculator to include output, request volume and supported cache or batch assumptions.
If two models use different encodings, compare provider-appropriate counts for the same underlying task. Reusing one count across every model may be acceptable for a rough sensitivity exercise, but label that assumption. For a decision close to a budget boundary, replace the rough method with the best available measurement.
Keep credentials, personal records and confidential production text out of the fixture. Use a synthetic or safely redacted example that preserves the structural features you want to measure. This tool is intended to calculate in the browser; a safe fixture also reduces the consequence of accidental copying or sharing outside the tool.
Last verified · Source ↗
Frequently asked questions
Is a token the same as a word?
Is the Claude token calculator exact?
Why do OpenAI encoding choices differ?
Does the count include my whole API request?
Can this predict the exact output length?
Is a missing model price a zero cost?
Should I use production secrets as sample text?
Sources
Last verified · Source ↗