AI Token Counter
AI Token Counter counts the tokens in your text with the o200k tokenizer used by GPT-4o and newer OpenAI models, and shows how much of an 8K to 1M context window it fills. Claude and Gemini use their own tokenizers, so their counts will differ.
How to use AI Token Counter
- Paste your prompt or document, or open a .txt or .md file.
- Read the token count and how much of each context window size it fills.
- To cut the count, convert HTML, Word or PDF files to Markdown first and count again.
Frequently asked questions
Which tokenizer does it use?
It uses o200k_base, the encoding OpenAI uses for GPT-4o and newer models, through the open-source gpt-tokenizer library. Chat apps and APIs add a few tokens of their own around each message, so a request can count slightly more.
Is the count right for Claude or Gemini?
Not exactly. Anthropic and Google use their own tokenizers, so their counts for the same text will differ. Use this number as a rough guide for them, and as the real count for OpenAI models.
Why does a chat use more tokens than this shows?
A chat also counts the system prompt, earlier messages, any files or images you attach and the model's reply. This tool counts only the text you paste.
How do I use fewer tokens?
Send clean text instead of raw formats. HTML, Word files and JSON carry markup the model has to read too. Converting them to Markdown keeps the headings and tables but drops most of that markup, and the converters here show the count before and after.
Is my text uploaded?
No. The tokenizer downloads once and runs in your browser, so your text never leaves your device.
Next step
Need the text out of a PDF first? Extract it, then count it here. Open PDF to Text.