What exactly is a token?

LLMs don’t read letters or words — they read integers. A tokenizer chops text into chunks from a fixed vocabulary (often 50,000 to 200,000+ entries) and maps each chunk to an ID. Common words are usually a single token; rare or long words are split into pieces.

TextLikely tokens (illustrative)Count
The cat satThe · cat · sat3
tokenizationtoken · ization2
ailearnistail · earn · ist~3
2026-10-13202 · 6 · - · 10 · - · 13~6

Notice the leading spaces: in most tokenizers the space belongs to the next word, so " cat" and "cat" are different tokens. Exact splits vary by model.

How tokenization works (byte-pair encoding)

Most modern LLMs use a variant of byte-pair encoding (BPE) or a similar sub-word method such as SentencePiece:

  1. Start with individual bytes or characters as the vocabulary.
  2. Scan a large training corpus and find the most frequent adjacent pair (e.g., t + h).
  3. Merge it into a new token (th) and repeat — thousands of times — until the vocabulary hits its target size.

The result: frequent strings (“ the”, “ing”, “ function”) become single tokens, while anything rare is spelled out from smaller pieces. Because it falls back to bytes, a BPE tokenizer can represent any text, including emoji and every language — just not equally efficiently.

Live token & cost estimator

Try it

Paste text to estimate tokens and cost

Uses the standard rules of thumb (≈4 chars or ≈0.75 words per token). The colour view shows an approximate sub-word split.

0characters
0words
0estimated tokens
$0per 1,000 calls (input only)

For exact counts use the Token Counter or your provider’s token-counting endpoint.

Rules of thumb: converting tokens to words

Tokens≈ English words≈ Real-world size
1¾ word~4 characters
10075 wordsA short paragraph
1,000750 words~1.5 pages
10,0007,500 wordsA long report
100,00075,000 wordsA full-length novel
1,000,000750,000 wordsA shelf of books or a large codebase

Non-English text, code and data cost more. Many languages written in non-Latin scripts, source code with lots of symbols and indentation, JSON and long numbers can need noticeably more tokens than English prose of the same length. Always measure your real data.

Tokens and the context window

The context window is the model’s working memory for one request, measured in tokens. Everything shares it:

  • the system prompt and instructions,
  • the conversation history,
  • retrieved documents (in RAG) and tool results (in agents),
  • and the output the model generates.

Today’s windows range from tens of thousands to over a million tokens depending on the model. Bigger isn’t automatically better: long prompts cost more, slow responses down, and models can overlook details buried in the middle of very long inputs. Retrieval that sends only the relevant chunks usually beats pasting everything.

How token pricing works

API providers charge per million tokens, with separate prices for input and output. Output tokens typically cost several times more than input tokens because they’re generated one at a time. The formula:

cost per call = (input_tokens  × input_price  / 1,000,000)
              + (output_tokens × output_price / 1,000,000)

monthly cost  = cost per call × calls per day × 30

Worked example (illustrative prices): a support assistant sends 2,500 input tokens (instructions + retrieved articles + question) and gets 400 output tokens back. At $3 / 1M input and $15 / 1M output, each call costs $0.0075 + $0.006 = $0.0135. At 20,000 calls a day that’s about $8,100 a month — and trimming retrieved context from 2,000 to 1,000 tokens saves roughly a fifth of it. Plug in your own numbers with the LLM Cost Estimator.

Many providers also discount cached input (a repeated prompt prefix such as long instructions) and batch jobs that don’t need an immediate response. Reasoning models may also generate hidden “thinking” tokens that are billed as output.

Token quirks that explain “weird” LLM behaviour

  • Letter counting: asking how many r’s are in “strawberry” is hard because the model sees a couple of tokens, not ten letters.
  • Arithmetic on long numbers: numbers split into uneven chunks, which makes digit-by-digit maths error-prone — use a calculator or code tool.
  • Word limits drift: the model plans in tokens, not words, so “exactly 100 words” is approximate.
  • Trailing spaces matter: a prompt ending in a space can produce odd continuations because the space normally belongs to the next token.

7 ways to use fewer tokens (and spend less)

  1. Send only the relevant chunks, not whole documents — tune chunk size and top-k.
  2. Summarise or truncate long chat histories.
  3. Keep stable instructions at the start of the prompt so prompt caching can apply.
  4. Ask for concise output and set a max-tokens limit.
  5. Use structured output instead of verbose prose when the result feeds code.
  6. Route simple requests to smaller, cheaper models.
  7. Use batch processing for non-urgent jobs where available.
Quick quiz

Token sense check