OpenAI token counter
Paste any text to count its tokens exactly as GPT-4o, GPT-4.1, GPT-5 and GPT-4 see them, plus characters and words. Useful for prompt budgets, context windows and API cost estimates.
- o200k_base & cl100k_base
- Exact tiktoken counts
- Free
Tokens
Characters
Words
Why count tokens?
LLM APIs bill and limit by tokens, not characters. Knowing the count tells you whether a document fits a model's context window, how much a request will cost, and how to size chunks for retrieval. For RAG, chunks of 300-800 tokens with a small overlap are a common starting point.
Need counts in code? The AnyToMarkdown API returns exact token counts for every converted document and chunk, and has a /v1/tokens endpoint for any text.
Frequently asked questions
Which tokenizer does GPT-4o use?
GPT-4o, GPT-4.1, GPT-5 and the o-series models use o200k_base. GPT-4, GPT-3.5 Turbo and the text-embedding-3 models use cl100k_base.
How many tokens is a word?
In English, about 1.3 tokens per word on average, or roughly 4 characters per token. Code, numbers and other languages usually take more tokens per word.
Are these counts exact?
Yes. The counter uses the same byte-pair encodings as OpenAI's tiktoken library, so counts match what the API bills for the text itself (chat formatting adds a few tokens per message).
Does it count tokens for Claude or Gemini?
Those models use their own tokenizers. The OpenAI counts are a reasonable estimate, but not exact for them.
How can I reduce tokens in a document?
Convert it to Markdown first. Markdown drops layout noise and HTML markup; for web pages that often saves 80-90% of the tokens. Try the URL to Markdown converter.