Skip to content
Salyro
Tool

Token counter

Count the tokens of a text or conversation for each model — exact with OpenAI's tokenizer in your browser, a marked estimate elsewhere — with cost and context.

What it does

Paste a text, or a request body with a conversation in it, and choose the models to count for. For each model the counter shows:

  • how many tokens it is, and how that number was made — exact or estimate, always written beside it;
  • what those tokens cost as input, on today's price list;
  • how much of the model's context window they fill.

With an OpenAI model chosen, the text is also drawn token by token, in alternating tints, so you can see where each token begins. Everything runs in your browser: the text is not sent anywhere.

How it counts

Exact — OpenAI's models. The counter runs OpenAI's own encodings, o200k_base and cl100k_base, in your browser. Which encoding a model uses is recorded per model, from OpenAI's tokenizer library, tiktoken. The counts are tested against tiktoken itself: the same numbers, token for token, on every fixture.

Estimate — Anthropic, Google and xAI. Their tokenizers do not run outside their own APIs, so the counter does not pretend to have them. It estimates ⌈characters ÷ 4⌉, the same rule Salyro itself uses when it has to estimate, and labels the number as an estimate. The cost and the context share computed from it are estimates too.

A conversation is read in any of the four request formats: OpenAI Chat Completions, OpenAI Responses, Anthropic Messages and Gemini generateContent. The format is detected from evidence; when a body could be two formats, you choose. What the model reads is counted: the text of every message, tool calls and results, and tool definitions. For GPT-4o and GPT-4o mini, the tokens OpenAI adds around each message are counted as its cookbook documents them. Anything that cannot be counted — images, reasoning blocks, framing a provider does not document — is listed, and the total is shown as "at least" (≥). Text split into several content parts is counted part by part; how a provider joins the parts is not documented, and the joined text can take a few tokens more or fewer, so when nothing else is open the total is marked approximate (≈), never "at least". When anything else was left out as well — an image, a reasoning block, or framing the provider does not document, a few tokens for every message — the total is shown as "at least about": a floor that can itself be a few tokens off.

The cost is the input alone, priced by Salyro's own cost arithmetic — the function it prices usage with — on the price in force today. The answer's output tokens are not included.

The context window comes from Reference Data, read off each provider's own page and dated. Where nobody could read it, it is shown as unknown.

What it does not know

  • Exact counts for Anthropic, Google and xAI. Counting through a provider's API needs a server and a key; this tool has neither.
  • The tokens a provider adds around messages, except where it documents them.
  • Very long runs of one character, like a hundred thousand identical letters. Exact counting slows down on them; after ten seconds the counter gives an estimate instead and says so.

FAQ

What is the difference between exact and estimate?

An exact count runs the same tokenizer the provider runs, and gets the same number. An estimate divides the number of characters by four. It is often close for English prose, and can be far off for code, numbers or other languages. Every number here says which one it is.

Why is Hebrew or Chinese text more tokens than English?

A tokenizer's vocabulary is learned mostly from English, so English words are often a single token while other scripts are split into more pieces. The Language Token Tax measures how much more.

Why are only the first few thousand tokens highlighted?

Drawing every token of a long document would make the page slow. The count always covers the whole text; the highlighting shows its start.

Is my text sent anywhere?

No. It is counted in your browser, in a Web Worker. If you share a link, the text is inside the link itself, after the #, which is never sent to a server — but whoever has the link can read it.

Sources

The encodings are OpenAI's, run with the gpt-tokenizer library and tested against OpenAI's tiktoken 0.14.0. The model-to-encoding mapping, the message framing and the context windows are Reference Data, each with its source page and date, listed in the public tools' data freshness report. Prices come from Salyro's model catalogue.

Where the numbers come from

  • Model and pricing data is a snapshot of the catalogue Salyro itself uses, taken when this site was built.
  • Facts about models and providers that are not in that catalogue carry their own source and the date they were checked, and are shown as unknown where no reliable source exists.