How misspellings wreck tokenization (and quietly cost you money)

A typo is not just embarrassing. To the model, it can be the difference between one token and twelve. Live demo of GPT-4o tokenization on correctly spelled vs misspelled text.

Type “antidisestablishmentarianism” into GPT-4o and the model sees a single token. Type “antidiestableshmentariansim” — the same word with three letters out of place — and the model sees twelve tokens. The meaning is gone. The cost just multiplied by twelve. You paid for both, and one of them was useful.

This is not a quirk. It is how every modern large language model reads text. Below is a live demo running the actual GPT-4o tokenizer in your browser. Type into either box and watch what happens.

Loading tokenizer (~150KB)…

Correct spelling
With misspellings
tokens will appear here
tokens will appear here
try these examples:

Why tokenizers exist at all

A language model does not read characters and it does not read words. It reads tokens — chunks of text that the model’s vocabulary recognizes as atomic units. GPT-4o has roughly 200,000 tokens in its vocabulary. The tokenizer’s job is to chop any input string into the longest sequence of these chunks that covers it.

When the chunks line up nicely with English words — which they do for nearly every common word in well-spelled text — you get one token per word. When the chunks don’t fit, the tokenizer falls back to smaller and smaller pieces until it can cover the input at the character level.

That fallback is what you saw with the misspelled example. The tokenizer knew about “antidisestablishmentarianism” because it appears in training data verbatim. It had no entry for “antidiestableshmentariansim” because no one has ever written that. So it broke the string into fragments — “anti”, “die”, “stable”, “sh”, “ment”, and so on — that do exist. The cost is twelve tokens for a string that should have been one.

A brief intuition for byte-pair encoding

The algorithm that produces these tokens is called Byte-Pair Encoding (BPE). The idea is straightforward:

Step 1: starteach char is a token[t][h][e]_[c][a][t]Step 2: count pairs”th” appears 800k timesth: 800k · he: 600k · _c: 200kStep 3: merge winner”t”+“h” becomes “th”[th][e]_[c][a][t]Repeat 50,000 timesuntil vocab is fullFinal: vocabulary of~200,000 tokensCommon strings collapse into single tokens.Rare strings stay as their constituent pieces.”The”=1 token · “Thxe”=3 tokens. The tokenizer never saw “Thxe” during training.

Start with every character as its own token. Count which adjacent pairs appear most often in the training corpus. Merge the most common pair into a new token. Repeat. After tens of thousands of merges, the vocabulary contains common words (“the”, “and”), common suffixes (“ing”, “ed”), common roots (“estab”, “lish”), and a long tail of rarer pieces. Anything the merge process never reached stays at the character level.

This is why a misspelling is so expensive. The tokenizer’s merges are frozen at training time. When you type “recieve” instead of “receive”, it cannot adapt. The string “recieve” was never frequent enough during training to deserve its own token. So the tokenizer splits it: probably “rec”, “iev”, “e” — three tokens for what should have been one.

Why this actually matters

Tokenization sits between you and the model in a way that is easy to forget about. Three concrete costs hit you when text tokenizes badly:

1. MoneyYou pay per token,in and out.2x tokens =2x bill2. Context windowBad tokens fill upyour context faster.Less room forreal content3. Model confusion”recieve” tokenizeslike nothing familiar.Worse answersfrom bad input

The first two are easy to measure. The third is more subtle but probably most important. When the model sees the token sequence for “receive”, it sees a single embedding that lives near other verbs about getting and accepting. When it sees the sequence for “recieve” — three fragments that mean nothing in isolation — it has to reconstruct the intended word from scratch using context. Modern LLMs are good enough to usually succeed, but they are working harder, and on hard prompts that work matters.

Why the demo above looks the way it does

A few things worth pointing out about what you saw when you typed:

The leading space matters. Notice that ” apple” (with a leading space) is one token, but “apple” at the start of a sentence is also one token — they are different tokens internally. The tokenizer handles word boundaries by attaching the space to the next word. This is why pasting text without preserving spaces sometimes tokenizes worse than you’d expect.

Common words win big. Type any word that appears frequently in English — “the”, “and”, “because”, “government” — and it costs one token. Type a rare variant — “governement” — and the cost can triple. The vocabulary was tuned for what people actually wrote, so it rewards common usage.

Capitalization changes things. “JavaScript” is one token. “JAVASCRIPT” is three. The tokenizer treats casing as semantically meaningful, which it sometimes is, but it also means that shouty text or randomly capitalized text costs more.

Code tokenizes surprisingly well. Programming languages have many repeated keywords that BPE captures efficiently. A line like for (let i = 0; i < arr.length; i++) tokenizes to about ten tokens, despite looking dense. The tokenizer has seen a lot of code.

What to actually do about this

A few practical takeaways:

For production systems that call LLM APIs at scale: validate and clean user input. Run a fast spell-check pass before sending text to a paid API. The cost savings on a high-volume system can be significant, and the model gets better input as a bonus.

For prompt engineers: when you find your prompts running long, look at the tokenizer view (OpenAI’s tokenizer is at platform.openai.com/tokenizer). Often you can cut tokens by rephrasing — using a common synonym for a rare word, removing redundant capitalization, fixing the typos you didn’t notice.

For everyone else: when ChatGPT or Claude gives you a worse-than-expected answer on a quick question, try retyping it without typos. You may have been asking the question in a way the model literally could not see clearly.

Notes on tokenizers for non-English languages

A final point worth knowing: the tokenization disadvantage is much larger for languages that were underrepresented in the training data. A Spanish sentence with 10 words might tokenize to 15 tokens; the same idea in Swahili could tokenize to 40 or more. Common Chinese characters mostly get their own tokens, but rare ones fragment. This is one of the practical reasons LLMs perform unevenly across languages — the input is literally more expensive and less coherent before reasoning even starts.

Try typing some non-English text in the demo above if you read another language. The contrast is often striking.

What I would build next

Next post in this thread: a working spell-check preprocessor as a Cloudflare Worker that sits in front of an LLM API call, with token savings measured before and after on a sample of real user queries.

// discussion

Comments

Replies use GitHub Discussions. You'll need a GitHub account to post.