German Bragin

LLM token counter

Paste any text or code to estimate how many tokens it uses, how it fits in a 200K or 1M context window, and what the input would cost.

0Estimated tokens
0 to 0Likely range
0Characters
0Words
0Lines

Estimate only. For an exact Claude count, call the count_tokens endpoint (see below).

By German Bragin · Updated · Free, no signup, runs in your browser

How the estimate works

The counter splits your text into words, numbers, symbols and non-Latin characters and applies typical tokens-per-character ratios for each. English prose lands near four characters per token. Code, JSON and URLs cost more because they contain many symbols, and Chinese, Japanese, Cyrillic and Arabic text costs more per character too. The "likely range" shows a margin of error because no heuristic can match a real tokenizer exactly.

Get an exact Claude token count

Claude has its own tokenizer, so do not use OpenAI's tiktoken to count Claude tokens. Anthropic provides a free token-counting endpoint:

import anthropic

client = anthropic.Anthropic()
count = client.messages.count_tokens(
    model="claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Your text here"}],
)
print(count.input_tokens)

It returns the input token count for exactly the request you would send, including system prompt and tools.

Why token counts matter

Tips to reduce tokens

Frequently asked questions

Is this token count exact?

No. It is an estimate computed in your browser, accurate to roughly 15 to 20 percent for English prose and code. Each model family has its own tokenizer, so only the provider's own counter gives an exact number. For Claude, use the count_tokens API endpoint.

What is a token?

A token is the unit a language model reads and writes: a word, part of a word, a number fragment or a punctuation mark. In English a token averages around four characters or three quarters of a word.

Why do code and non-English text use more tokens?

Tokenizers are trained mostly on English text. Source code, URLs, JSON and languages such as Chinese, Japanese, Russian or Arabic split into more, smaller pieces, so the same number of characters costs more tokens.

Is my text sent anywhere?

No. The estimate runs entirely in your browser. Your text is never uploaded or stored.

Do newer Claude models count tokens differently?

Yes. Anthropic changed the tokenizer with Claude Opus 4.7, and the same text can produce up to roughly 35 percent more tokens than on earlier models. Re-measure with the API when you migrate.

More free tools