File token counter

PDF Token Counter

Count the tokens in a PDF, Word document, TXT, Markdown, JSON or CSV file — and see what it will cost to send. This PDF token calculator extracts the text and tokenizes it entirely in your browser, so nothing is uploaded and no sign-up is needed.

Processed in your browser — no upload

Drop a PDF, DOCX, TXT, MD or JSON file

or click to browse — multiple files welcome

PDFDOCXTXTMDJSONCSVXMLHTMLYAML
Tokens
0
Words
0
Characters
0
Input cost
$0.0000
Context window0%
0 tokens used1M limit

Counts for OpenAI models are exact, produced by the same BPE tokenizer the API uses. Anthropic, Google, xAI, DeepSeek and Meta do not publish theirs, so those counts run your text through a BPE baseline and scale the result to the model’s own tokenizer — which is why Claude Opus 5 and Claude Sonnet 4.6 no longer report the same number.

Step by step

How to count tokens in a PDF

  1. 1

    Add your file

    Drop a PDF, DOCX, TXT, Markdown, JSON or CSV file onto the counter above, or click to browse. Several files at once is fine.

  2. 2

    Text is extracted on your device

    PDFs are read page by page with pdf.js; .docx archives are unzipped and their WordprocessingML walked in reading order. Nothing is sent anywhere.

  3. 3

    Pick the model you are billing against

    The count is recalculated with that model’s tokenizer — exact for OpenAI, a labelled estimate for providers who keep theirs private.

  4. 4

    Read the count, cost and context fit

    Tokens, words, characters and input cost, plus how much of the model’s context window the document would occupy.

Supported formats

Every file type this token calculator reads

One tool for documents, prose and structured data. The extraction differs per format; the tokenizer does not.

PDF

PDF token counter

The text layer is extracted page by page with pdf.js, up to 500 pages per file. Works on anything with real text — reports, contracts, papers, exported slide decks. Scans need OCR first, and the counter tells you when it hits one.

DOCX

DOC & DOCX token counter

A .docx is a ZIP archive, so the counter unzips it in the browser and reads word/document.xml directly — paragraphs, tables and line breaks in document order, with field codes and tracked deletions skipped. Legacy binary .doc has to be re-saved as .docx or PDF.

TXT

TXT token counter

Plain text is the simplest case: read as UTF-8 and tokenized exactly as it sits on disk. Useful for prompt files, transcripts, scraped copy and log excerpts you are about to paste into a model.

MD

Markdown (MD) token counter

Markdown is counted as written, with the syntax included — because that is what the model receives. Heading hashes, list bullets, table pipes and fenced code markers are all tokens you pay for, which is why a README often counts higher than its word count suggests.

JSON

JSON token counter

Braces, brackets, quotes, colons and indentation are all tokenized. Structured payloads are dramatically denser than prose — often close to one token per two characters — so counting before you inline a JSON blob into a prompt is worth the ten seconds. JSONL is supported too.

CSV

CSV, XML, YAML & HTML

Data and markup formats are read as text and counted verbatim. Repeated tags, delimiters and quoting overhead dominate the count, so a spreadsheet export can cost several times what the same data would as prose.

Token pricing

What a document costs, model by model

Input rates only — output is billed separately and typically costs three to five times more.

Input token pricing per model, including cost per 1,000 tokens, 200,000 tokens and 1,000,000 tokens, and tokens per US dollar
ModelPer 1M tokens1,000 tokens200,000 tokensTokens per $1
GPT-5.6 TerraOpenAI$2.00$0.00200$0.400500,000
GPT-5.6 LunaOpenAI$0.200$0.00020$0.0405,000,000
GPT-5.5OpenAI$5.00$0.00500$1.00200,000
Claude Sonnet 5Anthropic$2.00$0.00200$0.400500,000
Claude Haiku 4.5Anthropic$1.00$0.00100$0.2001,000,000
Gemini 3.1 ProGoogle$2.00$0.00200$0.400500,000
Gemini 3.7 FlashGoogle$0.750$0.00075$0.1501,333,333
Grok 4.6xAI$2.00$0.00200$0.400500,000
DeepSeek V4 FlashDeepSeek$0.440$0.00044$0.0882,272,727

Tokens, words and pages side by side

Approximate word count, page count and GPT-5.6 Terra input cost for common token amounts
Tokens≈ Words≈ PagesGPT-5.6 Terra input
1,0007501.5$0.00200
10,0007,50015$0.020
100,00075,000150$0.200
200,000150,000300$0.400
1,000,000750,0001,500$2.00

Assumes English prose at roughly 0.75 words per token and 500 words per page. Code, JSON and non-Latin scripts run considerably denser.

FAQ

Frequently asked questions

Counting & cost

How can I count tokens?

Run the text through the same tokenizer the model uses. OpenAI publishes theirs, so counts for GPT-5.6, GPT-5.4, GPT-4.1 and GPT-4o are exact — this page loads the real BPE vocabulary (o200k_base) in your browser and counts against it. Anthropic, Google, xAI, DeepSeek and Meta do not publish tokenizers, so those counts are approximations and are labelled "est." For a rough manual check on English prose, divide the character count by 4.

How to count tokens in a PDF file?

A PDF has to be turned back into text before it can be tokenized. Drop the file into the counter at the top of this page: it extracts the text layer page by page with pdf.js and tokenizes the result, entirely in your browser with no upload. If the count comes back empty, the PDF is almost certainly a scan with no text layer and would need OCR first.

How much is 1,000,000 tokens?

About 750,000 words, or roughly 1,500 pages of ordinary prose — five or six full-length novels. In money it depends entirely on the model: 1,000,000 input tokens costs $2.00 on GPT-5.6 Terra, $0.200 on GPT-5.6 Luna and $5.00 on GPT-5.5. Output tokens are billed separately and cost three to five times more.

How much is 200,000 tokens?

About 150,000 words, or roughly 300 pages — one full-length novel. It was the standard context-window ceiling for years, and the smaller models still stop there; the current flagships hold far more — GPT-5.6 Terra takes about 1,050,000 tokens, so a document that size no longer fills a request on its own. At GPT-5.6 Terra input rates it costs $0.400.

How much do 1,000 tokens cost?

1,000 input tokens costs $0.00200 on GPT-5.6 Terra, $0.00020 on GPT-5.6 Luna, $0.00200 on Claude Sonnet 5 and $0.00200 on Gemini 3.1 Pro. Providers quote prices per million tokens, so divide the headline rate by 1,000 to get the per-1,000 figure.

How to calculate token price?

Price = (input tokens ÷ 1,000,000) × input rate + (output tokens ÷ 1,000,000) × output rate. Count the two directions separately, because every provider charges more for what the model writes than for what you send it. If you reuse the same prompt prefix across requests, check whether a cached input rate applies — it is typically 10% to 50% of the standard rate.

How do tokens cost money?

Providers meter usage by token because tokens are what the model actually processes: every token in your prompt and every token in the reply consumes compute. You are billed for both directions on every request, which is why a long document resent on each turn of a conversation gets expensive quickly — the same pages are paid for again each time.

How do you measure a token?

A token is a subword unit from the model’s byte-pair-encoding vocabulary — not a character and not a word. Common English words are usually one token; longer or rarer ones split into several, so "tokenization" becomes "token" + "ization". Punctuation and leading spaces count as well. English averages about 4 characters or 0.75 words per token, but code, JSON, non-Latin scripts and emoji are far denser, sometimes a token per character.

How many tokens is $1?

One dollar of input buys about 500,000 tokens on GPT-5.6 Terra, 5,000,000 on GPT-5.6 Luna, 200,000 on GPT-5.5 and 500,000 on Claude Sonnet 5. Divide 1,000,000 by the model’s per-million input price to get the figure for any model in the table above.

Uploading files

Which file types can I upload to the token calculator?

PDF, DOCX, TXT, Markdown (.md), JSON, JSONL, CSV, TSV, XML, HTML, YAML and plain log files. PDFs are parsed with pdf.js, .docx files are unzipped and read from their WordprocessingML, and everything else is read as UTF-8 text. Legacy binary .doc is not supported — save it as .docx or PDF first.

Are my uploaded files private?

"Upload" here only means your browser reads the file from your disk. PDF parsing, .docx unzipping and tokenization all run as JavaScript on your device, and the tokenizer vocabularies are served from this site rather than a third-party CDN. No file content is transmitted, logged or stored, so confidential contracts and internal documents are safe to check.

What is the largest file I can upload?

10 MB per file, and PDFs are read up to their first 500 pages. Both limits exist to protect your own browser tab — extraction is sequential, and holding every page of a very large document in memory at once will freeze it. When a PDF is capped, the file row says how many pages were read.

Can I count tokens in a scanned PDF?

Not directly. A scan is an image of text with no text layer, so there is nothing to extract and the counter reports that no text was found. Run the file through OCR first — most PDF tools have a "recognise text" option — then upload the searchable PDF it produces.

Can I upload more than one file at once?

Yes. Select or drop several files and each gets its own row with its own token count, while the stat cards show the combined total. That combined figure is the one that matters if you plan to concatenate the documents into a single prompt.

Can I count tokens in a Word document (.docx)?

Yes, for .docx and .docm. The counter unzips the archive, reads word/document.xml and walks its paragraphs, tables and line breaks in reading order, skipping field codes and tracked deletions. Headers, footers and footnotes live in separate parts of the archive and are not included in the count.

Does the PDF token counter work with password-protected PDFs?

No. An encrypted PDF cannot be parsed without its password, and the counter reports it as protected rather than guessing. Open it with the password and re-save it, or use your PDF tool’s "remove security" option, then upload the unprotected copy.

How accurate is the token count?

Exact for OpenAI models, because it uses the same BPE vocabulary the API uses — a count of 12,431 tokens for GPT-5.6 is the number you will be billed for on that text. For Anthropic, Google, xAI, DeepSeek and Meta the figure is an estimate, marked "est.", and is usually within 10–15% on English prose. Extraction varies more than tokenization does: a PDF’s reading order, tables and column layout affect which whitespace ends up in the text, and whitespace is tokenized too.

Why is my PDF’s token count higher than I expected?

Usually layout. Tables, multi-column pages, headers repeated on every page and hard line breaks all survive extraction, and every one of those newlines and stray spaces is a token. Scanned pages mixed into an otherwise text-based PDF drop out entirely and push the count the other way. Open the extracted-text panel under the counter to see exactly what was tokenized.

Do I need an account or an API key to use this?

No. There is no sign-up, no API key and no rate limit. The tokenizers run locally in your browser, so there is no service to authenticate against and nothing to meter.

Counting pasted text instead?

The main token calculator shows tokens as you type, with a colour-coded breakdown of how your text is split and a side-by-side price comparison across every model.