Developers and AI

Token counter for files: count tokens in a PDF, Word or Excel file

Count tokens in a PDF, Word, Excel or text file in your browser. Exact OpenAI counts, marked Claude and Gemini estimates, context fit and input cost.

DealMahal team · Published 6 December 2026 · 7 min read

A token counter tells you how many tokens a text or file will use when you send it to an AI model, so you know before you paste whether it fits and roughly what it costs. Our free token counter takes pasted text or a PDF, Word, Excel, CSV, Markdown or TXT file. It gives exact OpenAI counts, clearly marked estimates for Claude and Gemini, and a table of which models the text fits and what one call costs. Everything runs in your browser, so the file is never uploaded.

Why the same text has different token counts

Models do not read letters or words. They read tokens, which are pieces of words, whole words, punctuation and spaces, and each model family cuts text into tokens with its own tokenizer. The same paragraph can therefore be one number for an OpenAI model and a different number for Claude or Gemini.

OpenAI publishes its tokenizers, so its counts can be reproduced exactly on your own computer. Anthropic and Google do not publish an offline tokenizer for their current models. That is why the tool labels its Claude and Gemini numbers as estimates and shows them as a range, rather than pretending to a precision it does not have.

How to count tokens, step by step

  1. Open the token counter.
  2. Choose or drop a file: PDF, Word (.docx), Excel, CSV, Markdown or TXT, up to 50 MB. JSON, XML, HTML, YAML and log files work too. Or paste text into the box. Short pastes are counted a moment after you stop typing; for longer ones, press Count tokens.
  3. Read the result cards: OpenAI tokens (o200k_base), OpenAI tokens (older) (cl100k_base), Claude tokens and Gemini tokens (both shown as "about" a range), and Characters, with words and lines underneath.
  4. In Leave room for the answer (tokens): set how many tokens you want to keep free for the reply. It starts at 4,000.
  5. Read the table Does it fit? Context window per model. For each model it shows the context window, your text in tokens, the share of the window it uses, whether it fits, and the input cost.

OpenAI tokenizer: which count do I use?

The tool counts with two OpenAI encodings at once:

CardEncodingUsed by (per OpenAI's tiktoken)
OpenAI tokenso200k_baseGPT-4o, GPT-4.1 and GPT-5 family
OpenAI tokens (older)cl100k_baseGPT-4, GPT-3.5 and embeddings

Both counts are exact, and they are made on your device. Big texts are counted in a background worker so the page stays usable, with a percentage shown while it works. The text is split into parts only at points where the tokenizer never joins characters, so the total of the parts is the same as counting the whole text in one go.

One honest caveat, which the tool also prints: OpenAI has not published which tokenizer its GPT-6 models use, so the GPT-6 rows in the fit table assume o200k_base, the GPT-5 tokenizer, and are marked "assumes o200k_base". Their real counts may differ.

Claude token counter: what the estimate is based on

For Claude the tool uses Anthropic's published averages. On the tokenizer used since Claude Opus 4.7, 1 million tokens is roughly 555,000 words or 2.5 million characters. Older models such as Claude Haiku 4.5 make about 30% fewer tokens for the same text. The tool works out a word-based figure and a character-based figure and shows both ends as a range.

For Gemini it uses Google's rule of thumb: a token is about 4 characters, and 100 tokens are about 60 to 80 English words.

Here is the arithmetic for an example document of 10,000 words and 60,000 characters:

Model familyCalculationShown as
Claude (4.7 and newer)10,000 / 0.555 and 60,000 / 2.5about 18,018 to 24,000
Gemini60,000 / 4, 10,000 / 0.8 and 10,000 / 0.6about 12,500 to 16,667

Code and text that is not in English can sit further from these averages. When you need the exact Claude number, use Anthropic's free token counting API. Google's Gemini API has a countTokens method for exact Gemini counts.

Count tokens in a PDF, Word or Excel file

Pasting a long PDF into a box loses its tables and takes time. Dropping the file in is the quicker route, and the tool tells you exactly what it counted.

  • PDF: the text inside the PDF is counted, with tables written as Markdown tables. A note shows how many pages were read. Pages with no text are skipped, and the note says how many, since they may be scanned images. Remember that ChatGPT, Claude and Gemini may also count each uploaded page as an image, which adds tokens on top of the text.
  • Scanned PDF: if there is no selectable text at all, you see "has no selectable text" instead of a count. A scan needs OCR (text recognition) first.
  • Word (.docx): counted as Markdown text, with headings, lists and tables kept. Images are not counted. Old .doc files are not supported; save the file as .docx in Word first.
  • Excel, ODS: every sheet is counted as a Markdown table, with the number of sheets shown. The same data sent in another format, such as CSV, gives a different count.

If you want the exact text that was counted, our PDF to Markdown and Word, Excel and CSV to Markdown tools produce it as a file you can read, edit and paste.

Context window calculator: will it fit?

The fit table answers the question you usually have: can I send this in one go? For each model it compares your text plus the room you reserved for the answer with the model's context window, and shows one of three results:

  • Yes: the text and the reserved room both fit.
  • Only without the room for the answer: the text fits, but not with the room you asked for.
  • No: the text alone is bigger than the window.

For Claude and Gemini the check uses the top of the estimated range, so a "Yes" errs on the safe side. In the model table checked on 5 December 2026, context windows run from 200,000 to 1,050,000 tokens. The date and the source pages for every model are listed under the table.

Keep a margin. Chat apps add their own instructions and your earlier messages to every request, so a conversation uses more of the window than your text alone.

What one call costs

The last column shows the cost of sending your text once as input, at each provider's standard list price per million input tokens, without caching or batch discounts. Some models charge more per token once a prompt passes a certain size, and the column applies those tiers. The answer (output tokens) costs extra, and for Claude and Gemini the cost is a range that follows the token estimate.

The arithmetic is simple, if you want to check it. As an example, 120,000 tokens at a price of $2 per million input tokens is 120,000 x 2 / 1,000,000 = $0.24. Prices change often, so check the provider's own page before you rely on a figure.

Your file stays on your computer

Token counters that ask you to upload a file send your contract, report or customer list to someone else's server just to count it. This one counts on your device. The only things the page downloads are the tokenizer files and file readers from our own site, and your text is never sent anywhere. If the document holds personal details you do not want an AI model to see, remove them first with our private data redactor.

The same approach is behind our PDF table to Excel converter: useful work on sensitive files, without the upload.

Limits to know

LimitValue
File size50 MB
Text that can be counted60,000,000 characters
Paste box20,000,000 characters
Time limit for one count180 seconds
Not readOld .doc files, text in images, scanned pages without OCR

Frequently asked questions

What is the difference between o200k_base and cl100k_base?

They are two of OpenAI's tokenizers. OpenAI's tiktoken lists o200k_base for GPT-4o, GPT-4.1 and GPT-5 models, and cl100k_base for GPT-4, GPT-3.5 and embeddings. The token counter shows both, and both counts are exact.

Is there an exact Claude token counter?

Not offline. Anthropic has no downloadable tokenizer for current Claude models, so the tool shows an estimate as a range. For an exact number, use Anthropic's free token counting API, which counts for a given Claude model.

Why does a chat app use more tokens than the count for my PDF?

The tool counts the text inside the PDF. When you upload a PDF to ChatGPT, Claude or Gemini, they may also count each page as an image, and chat apps add their own instructions and earlier messages to every request.

Is my file uploaded?

No. Counting happens in your browser. The only downloads are the tokenizer files from our own site, and your text is never sent anywhere.

How much room should I leave for the answer?

The box starts at 4,000 tokens. Raise it if you expect a long answer. The fit table then shows Yes, No, or Only without the room for the answer for each model.

More free tools for getting files into AI and back out again are on the tools page.

Spotted an error? Write to dealmahal.official@gmail.com.

Questions or corrections: dealmahal.official@gmail.com.

Keep reading

All posts