File Token Counter

Count tokens in PDF, Word, Excel, CSV or JSON, several files at once, right in your browser. Shows context window usage. No upload.

How useful is this tool?

The result will appear here …

How to use this tool (video)

This video is hosted on YouTube. When you play it, data may be sent to Google.

File Token Counter: Count Tokens in PDF, Word and Excel

Want to know how many tokens a whole document takes up at an AI model? The file token counter reads PDF, Word (DOCX), Excel (XLSX), CSV, JSON and text formats directly in your browser and counts tokens with the official OpenAI tokenizer o200k_base (GPT-4o, GPT-5.x, GPT-6) or the older cl100k_base. The table shows each file separately plus the total. Nothing gets uploaded, all processing runs on your device.

How it works

Drop files into the input field, pick the tokenizer and click Count tokens. The tool extracts the text of each document: PDF via the text layer, Word via the document paragraphs, Excel via the stored cell values of every sheet, CSV, JSON and text directly. For PDFs, the file list shows progress for each page. It then counts tokens, characters and words per file and shows how much of the context window the total uses on the current models.

What it is good for

  • Checking whether a long document fits the context window before sending it to a model
  • Estimating API costs before processing documents
  • Comparing how file formats differ in token cost
  • Checking a whole document package at once instead of file by file

What the counter really measures

The counter reads the plain text of a document. For PDF that is the text layer: scans without a text layer get an OCR message rather than a misleading zero. If only some pages have text, the tool counts that text and flags the pages without it. For Excel it counts cell contents, not the table structure. Formula expressions, formatting and layout do not count. The count covers extracted text, not images, file metadata or additional prompt tokens. For Claude and Gemini, OpenAI tokens are a comparison, not an exact count for their tokenizers. The provider's own response remains authoritative for API billing.

Context windows of the current models

  • GPT-6 / GPT-6.1 / GPT-5.6: 1,050,000 tokens
  • Claude Opus 5.5 / Sonnet 5.5: 1,000,000 tokens
  • Gemini 4 Argon: 1,048,576 tokens, unified window for input and output
  • GPT-4o / GPT-4.1 / o1: 128,000 tokens
  • GPT-4 / GPT-3.5 Turbo: 8,192 tokens (legacy)

Frequently asked questions

Are my files uploaded?

No. PDF, Word and Excel are opened and read directly in your browser, and token counting runs locally too. Your files never leave your device.

How many files can I count at once?

Up to 20 files per run. The table lists each file with tokens, characters and words, and the total below comes with the context window usage.

Why can the counter not read my PDF?

The counter needs a text layer. Scans without text get an OCR message next to the file. Run text recognition first, then load the PDF again. Encrypted PDFs, including those that open without asking for a password, need a decrypted copy first. Damaged files and missing libraries get their own error messages. Only successfully counted files enter the total.

Which formats are supported?

PDF, Word (DOCX), Excel (XLSX), CSV and TSV, JSON, plus text formats like TXT, Markdown, XML, HTML and source code. Old Word formats (.doc) and binary formats are not read.

How accurate is the count for GPT-6?

The counter uses the o200k_base tokenizer, the same one as GPT-4o and the GPT-5 family. That is the common basis for the GPT-6 models, but OpenAI has not officially confirmed the mapping yet. Treat the number as a very good estimate, not a guarantee.

What does counting large files cost?

Nothing. The calculation runs in your browser, you need no account and can count up to 20 files per run. Very large files are capped at 2 million characters each, the table says so when it happens.

Read more about this tool

Why files instead of a text field?

A prompt with an attached document consumes the tokens of the document, not just those of your question. Anyone who wants to know whether a 20-document package, a manual or a data export fits the window would otherwise paste every file into a text field by hand. The file token counter takes up to 20 selected files at once and runs the total against the context windows of the current models.

How the extraction works

pdf.js reads PDF files page by page and combines their text. Word files are ZIP archives: the counter opens them locally and collects the text paragraphs from the document XML. Excel files work the same way, the counter resolves each cell’s text reference, includes repeated and inline text and reads numeric values. Unused entries in the internal string table do not count. For formulas, it uses the saved result and does not recalculate the formula. CSV, JSON and text formats are read directly. After that the same tokenizer takes over as in the token counter for text.

Tokens vs. characters in documents

For English prose the rule of thumb is one token per four characters or 0.75 words. German documents usually sit a little higher because of compound words, tables and JSON much higher because of numbers and punctuation. That is why a real count with the tokenizer is the only reliable number: a character-based estimate can be off by multiples for structured data.

Does everything run locally?

Yes. Extraction and token counting happen entirely in your browser, there is no upload and no server contact for your files. You can count confidential contracts, invoices or customer data without sending them anywhere.