Token visualizer
Models do not read characters or words — they read tokens. Seeing exactly where your text breaks into tokens explains why billing, context limits, and even model behaviour sometimes surprise you. This visualizer colors each token as its own chip so you can spot subword splits, whitespace handling, and the hidden cost of numbers and rare words.
How it works
The tool applies a byte-pair-style splitter modeled on cl100k_base, the tokenizer
GPT-4o uses. It first segments on the same boundaries the real regex uses — contractions,
runs of letters, runs of digits, punctuation, and leading spaces — then merges short
common fragments the way BPE would. Crucially, a leading space stays attached to the
word after it, which is why token counts as one token rather than two. Long digit
runs and uncommon words break into multiple subword tokens, which the colored chips make
immediately visible.
What the chips reveal
Common English words are almost always a single token. “the”, “is”, “you”, “have” each occupy one chip. That is the core efficiency of BPE tokenization for everyday prose.
Uncommon words and technical jargon often split. “Tokenization” itself may become two chips: “Token” and “ization”. A medical term or a product-specific proper noun can split into three or four fragments, costing more than you might expect.
Numbers split unpredictably. Four-digit years like “2024” often tokenize as a single token because they appear frequently in training data. But a 10-digit ID or a long price like “1,234,567.89” breaks into many single-digit or two-digit chunks. If you embed transaction IDs or invoice numbers in prompts at scale, the token cost adds up.
Code is generally efficient for keywords but expensive for long variable names, hashes, and base64 strings. A 64-character hex SHA-256 hash can cost 15–20 tokens on its own.
Non-Latin scripts are the most dramatic case. A single Chinese or Japanese character is often a single token, which sounds good, but one character carries far less information than one English word — so you need many more characters to convey the same meaning, and the effective cost per semantic unit is higher.
Reading the results for prompt optimization
Paste your system prompt and look for chips that surprise you. Clusters of single-character chips inside what should be a common phrase often mean a typo, an unusual encoding, or a Unicode lookalike character that broke the vocabulary match. Long chains of short chips inside a number or an identifier are a signal to consider whether you need that value verbatim.
Tips and notes
- If a chip splits a common word into pieces, that word is rare in the vocabulary — rephrasing with more common words can shave tokens off long prompts.
- Numbers, IDs, and hashes are token-hungry; consider whether you really need them verbatim in a prompt you send thousands of times.
- Watch out for invisible whitespace characters (non-breaking spaces, zero-width joiners) that create unexpected token boundaries and inflate counts silently.
- For an exact production count, call the provider’s tokenizer or
count_tokensendpoint — use this visualizer for intuition and quick estimates.