Skip to content

AI Tokenizer

Runs the real byte-pair encoding in your browser — o200k_base, cl100k_base, or p50k_base — instead of dividing the character count by four. That rule of thumb comes from English prose, and it is badly wrong about JSON, source code, and any script that is not Latin, which is most of what actually ends up in a production prompt. Shows every token boundary, what the text costs at a rate you set, and how much of a context window it consumes. Nothing is uploaded.

Runs in your browser Text

Downloading the vocabulary… The vocabulary is fetched once per encoding, then everything runs locally.

What this actually tells you

A token is a byte-pair-encoded fragment, not a word and not a character. Common English words are usually one token each; a rare word, a variable name, a UUID, or a base64 blob breaks into several. That is why the ÷4 rule holds up on prose and falls apart on everything else — JSON keys, punctuation runs and indentation each cost a token, and characters outside the Latin scripts routinely cost one to three tokens each. Load the sample above and compare the paragraph against the JSON and the Japanese line.

These are OpenAI's tiktoken vocabularies, so the counts are exact for the models that use them: o200k_base for GPT-4o, GPT-4.1, the o-series and GPT-5; cl100k_base for GPT-4, GPT-3.5 Turbo and the text-embedding-3 models; p50k_base for GPT-3 and the legacy Codex models.

Claude is not on that list, deliberately. Anthropic does not publish a tokenizer for current Claude models, so no browser-side library can count them — anything claiming to is quietly showing you a GPT count. Use the API's POST /v1/messages/count_tokens endpoint, which is free to call and counts the whole request rather than a string. It matters more than it used to: Claude Opus 4.7 introduced a new tokenizer, also used by Opus 4.8 and Fable 5, that can emit up to about 1.35× as many tokens as the older Claude tokenizer on the same text, so a baseline taken against an earlier model does not carry forward.

Finally, this counts a string. A real request also carries the per-message chat framing, the system prompt, and every tool definition you declared — all billed as input, all counted against the window. Budget from the request, not from the paragraph.