Tokenization Visualizer
See exactly how text splits into GPT tokens, colour-coded chip by chip, with OpenAI tiktoken (o200k & cl100k). Free, runs entirely in your browser.
Tokenization Visualizer
This shows OpenAI's tokenizer only: the real tiktoken encodings, so each coloured chip is exactly one token of that encoding, and the count is exact for the text. A chat request adds a few tokens per message for its formatting. Claude, Gemini and Llama use their own tokenizers, which this page does not have; they split the same text differently.
How to Use the Tokenization Visualizer
Pick the model encoding
Choose o200k_base for GPT-5, GPT-4.1, GPT-4o and the o-series, or cl100k_base for GPT-4, GPT-3.5 and the embedding models. The encoding decides exactly where the token boundaries fall.
Paste your text
Type or paste any prompt, sentence or snippet of code. The visualizer runs OpenAI's exact tokenizer entirely in your browser and redraws the chips live as you edit.
Read the coloured chips
Each chip is one token, showing the actual text the model sees. Adjacent tokens use different colours so boundaries are easy to spot — a middle dot marks a space, an arrow marks a newline.
Learn the quirks
Watch how a leading space joins a word, how rare words shatter into pieces, and how numbers and emoji fragment. Hover a chip to see its position and token id.
Tokenization: How a Model Actually Reads Your Text
From characters to tokens
A large language model never sees your text the way you do. Before a single word reaches the network, a tokenizer chops the raw string into a sequence of tokens — small, reusable chunks drawn from a fixed vocabulary of tens of thousands of entries. Each token maps to an integer id, and it is that stream of integers, not the letters, that the model reads, predicts, and bills you for. Tokenization is the invisible first step that shapes everything downstream: how long your prompt counts as, how much it costs, and even how well the model reasons about the pieces of a word.
The dominant scheme for modern models is Byte Pair Encoding, or BPE. It starts from individual bytes and repeatedly merges the most frequent adjacent pair into a new symbol, learned once over a giant training corpus. Common words like the, and, or token survive as a single token because they appear constantly; rarer or longer words get assembled from several sub-word fragments. This is a deliberate trade-off — a vocabulary small enough to be efficient, yet expressive enough to spell out any word, name, or typo it has never seen by falling back to smaller pieces, all the way down to raw bytes if needed. Nothing is ever truly out-of-vocabulary; worst case, a string is encoded one byte at a time.
Spacing matters more than people expect. In these encodings a leading space is usually glued to the following word, so "token" at the start of a string and " token" mid-sentence are different tokens with different ids. That is why this visualizer marks spaces with a middle dot and newlines with an arrow: the whitespace is part of the token, not a gap between tokens, and seeing it explains a lot of otherwise baffling counts.
Why "strawberry" splits oddly — and why it matters
The famous example is strawberry. Ask a model how many letter "r"s it contains and it often stumbles — not because it can't count, but because it never sees the individual letters. At the start of a text, cl100k_base splits strawberry as str + aw + berry and o200k_base as st + raw + berry. In the middle of a sentence, " strawberry" with its leading space is a single token in both, so the model gets one id and no letters at all. The example in the box above shows the second case; delete "The " to see the first. The same effect makes models weak at spelling, reversing strings, and character-level arithmetic: those tasks live below the resolution of the token.
This has very practical consequences. Token boundaries decide your real cost, since APIs charge per token, and your real context limit, since the window is measured in tokens, not words. Non-English text, especially scripts far from the training data, can use several tokens per character and quietly blow past budgets. Code tokenizes unevenly because of symbols and indentation. Even a stray emoji can expand into many tokens. Seeing the split — rather than trusting a rough "four characters per token" rule — lets you trim prompts intelligently, design better chunking, and understand why a model behaves the way it does on the letters inside a word. This tool shows you the genuine article, computed locally from the same encoding tables the OpenAI API uses.
Disclosure: RECATOOLS is written with the assistance of Claude, made by Anthropic. Claude's tokenizer is not shown here, and the page names it only to say so.
Frequently Asked Questions
- BPE is the algorithm behind most modern tokenizers. It starts from individual bytes and repeatedly merges the most frequent adjacent pair into a new symbol, learned over a huge corpus. The result keeps common words whole while breaking rare words into reusable sub-word pieces — efficient, yet able to spell out anything.
- It depends where it stands. Mid-sentence, " strawberry" with its leading space is one token in both encodings; at the very start of a text it is three, str + aw + berry in cl100k_base and st + raw + berry in o200k_base. Either way the model sees ids, not letters, which is why counting the "r"s is hard for it.
- Use o200k_base for GPT-5, GPT-4o and GPT-4.1. Use cl100k_base for GPT-4, GPT-3.5-Turbo and the text-embedding models. The same text can split differently under each, so match the encoding to the model you'll actually call.
- In these encodings a leading space is glued to the word that follows it, so it's part of the token rather than a gap between tokens. We render it as a middle dot (and newlines as an arrow) so you can see exactly where the whitespace lives inside each chip.
- Yes, for OpenAI models. It runs OpenAI's own tiktoken encodings (cl100k_base and o200k_base) in your browser — the same tables the API uses — so both the count and the boundaries are exact. Other vendors use different tokenizers, so their counts will differ.
- No. Anthropic's Claude, Google's Gemini and Meta's Llama each use their own vocabulary and merge rules, so the same sentence can produce a different number of tokens and different boundaries. Use this tool for OpenAI models and the provider's own tools for an exact count elsewhere.
- No. The tokenizer runs entirely in your browser using a locally-served library. Your text is never uploaded to any server, model, or third party, and nothing is stored. The only network request is your browser fetching the tokenizer file from our own domain.
- To keep the page responsive we draw the first 2,000 token chips and summarise the rest as "+N more". The headline token count still reflects every token in your text — only the visual chips are capped.
Method & sources
How it computes
OpenAI tiktoken encodings (o200k_base, cl100k_base) run in the browser, so the ids and the count are exact for those encodings and no other. Tokens are grouped until their bytes end on a UTF-8 character boundary: a character spread over several tokens is shown once, with each token's bytes in hex (TokenViewKernel). Characters are counted as code points.
What this tool implements
- The page shows OpenAI's tokenizer only, and says so beside the tool. Claude, Gemini and Llama tokenizers are not available here and are not approximated.
- Model to encoding as tiktoken/model.py maps it: gpt-5, gpt-4.1, gpt-4o, o1, o3 and o4-mini to o200k_base; gpt-4, gpt-3.5-turbo and the text-embedding-3 models to cl100k_base.
- The count is for the text. A chat request adds a few tokens per message for its formatting, and the page says that.
- Corrected 2026-11-03: U+FFFD drawn for characters split across tokens; characters counted in UTF-16 units; "strawberry splits into str·aw·berry" (true only at the start of a text and only in cl100k_base; o200k_base gives st·raw·berry, and mid-sentence it is one token in both). Ten fact cards that repeated the prose, an unsourced pull-quote and two FAQs cut. Anthropic disclosure added.
Sources
- OpenAI. tiktoken — model-to-encoding map (tiktoken/model.py), read 2026-11-03: https://github.com/openai/tiktoken/blob/main/tiktoken/model.py
- js-tiktoken, the JavaScript port of tiktoken (MIT), vendored at /assets/vendor/js-tiktoken/: https://github.com/dqbd/tiktoken/tree/main/js
- Yergeau F. UTF-8, a transformation format of ISO 10646. RFC 3629. IETF; 2003: https://www.rfc-editor.org/rfc/rfc3629
What can make this go out of date
- None at runtime beyond the page's own vendored tokenizer tables; the text typed stays in the browser.
Pick up where you left off
Stored only in this browser — never sent to our servers.